Centos7 YUM安装MariaDB 10.0

Centos7 YUM安装MariaDB 10.0

安装步骤(新装)

  1. 配置添加yum源文件

vim /etc/yum.repos.d/mariadb.repo

# MariaDB 10.0 CentOS repository list - created 2016-05-30 02:16 UTC# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
#baseurl = http://yum.mariadb.org/10.0/centos7-amd64
baseurl = http://archive.mariadb.org/mariadb-10.0.10/yum/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck= 0

其他版本请参照官网修改版本号

  1. 查配置yum源对应的mariadb版本是否正确yum makecache yum info MariaDB-server
  2. 安装MariaDB-server和Client yum install MariaDB-server MariaDB-client MariaDB-devel -y 注:如果有提示和以前安装的版本冲突,您可能需要先移除以前安装的包,例如: yum remove mariadb-libs.
  3. 新建数据目录并创建mysql用户mkdir -p /data/dbdata/data/ && useradd mysql -s /sbin/nologin
  4. 初始化数据库目录mysql_install_db --datadir='/data/dbdata/data/'
  5. 修改权限并手工命令启动chown mysql:mysl /data/dbdata/data/ -R cd '/usr' ; /usr/bin/mysqld_safe --datadir='/data/dbdata/data/' &
  6. 初始化数据库权限 mysql_secure_installation

安装步骤(在同一台MYSQL服务器上安装)

  1. 配置添加yum源文件

vim /etc/yum.repos.d/mariadb.repo

# MariaDB 10.0 CentOS repository list - created 2016-05-30 02:16 UTC# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
#baseurl = http://yum.mariadb.org/10.0/centos7-amd64
baseurl = http://archive.mariadb.org/mariadb-10.0.10/yum/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck= 0

其他版本请参照官网修改版本号

  1. 查配置yum源对应的mariadb版本是否正确yum makecache yum info MariaDB-server
  2. 安装MariaDB-server和Client yum install MariaDB-server MariaDB-client MariaDB-devel -y 注:如果有提示和以前安装的版本冲突,您可能需要先移除以前安装的包,例如: yum remove mariadb-libs.
  3. 新建数据目录并创建mysql用户mkdir -p /data/dbdata/data/ && useradd mysql -s /sbin/nologin
  4. 初始化数据库目录mysql_install_db --datadir='/data/dbdata/data/'或者mysql_install_db --defaults-file=/etc/mariadb/etc/my.cnf
  5. 修改权限并手工命令启动chown mysql:mysl /data/dbdata/data/ -R cd '/usr' ; /usr/bin/mysqld_safe --datadir='/data/dbdata/data/' &或者mysqld_safe --defaults-file=/etc/mariadb/etc/my.cnf &
  6. 初始化数据库权限mysql_secure_installation --defaults-file=/etc/mariadb/etc/my.cnf或者mysql -h 127.0.0.1 -uroot -p -P3307 grant all privileges on *.* to 'root'@'localhost' identified by 'password'; grant all privileges on *.* to 'root'@'127.0.0.1' identified by 'password'; flush privileges ;

生产数据库配置(仅供参考)

[mysqld]
port        = 3307
socket      = /tmp/mysql_mariadb.sock
character-set-server = utf8
collation-server = utf8_general_ci
innodb_page_size=16384
lower_case_table_names=1
server-id=10
innodb_buffer_pool_size=10G
skip-name-resolve
datadir = /data/dbdata/data/
relay-log = /data/dblogs/relay/relay.log
log-error = /data/dblogs/mysqld.err
tmpdir = /data/dbdata/tmpdir
innodb_flush_log_at_trx_commit = 0
sync_binlog = 0
query_cache_type = 0
query_cache_size = 0
bulk_insert_buffer_size = 2G
innodb_log_buffer_size = 256M
innodb_log_file_size = 1G
innodb_write_io_threads = 16
innodb_doublewrite=0
auto_increment_increment = 1
auto_increment_offset = 1
autocommit = ON
character_set_server = utf8
connect_timeout = 10
default_week_format = 0
delay_key_write = ON
delayed_insert_limit = 100
delayed_insert_timeout = 300
delayed_queue_size = 1000
div_precision_increment = 4
event_scheduler = OFF
group_concat_max_len = 1024
innodb_concurrency_tickets = 5000
innodb_large_prefix = OFF
innodb_lock_wait_timeout = 7200
innodb_max_dirty_pages_pct = 70
innodb_old_blocks_pct = 37
innodb_old_blocks_time = 1000
innodb_purge_batch_size = 300
innodb_read_ahead_threshold = 56
innodb_stats_method = nulls_equal
innodb_stats_on_metadata = OFF
innodb_stats_sample_pages = 8
innodb_strict_mode = OFF
innodb_table_locks = ON
innodb_thread_concurrency = 0
innodb_thread_sleep_delay = 10000
interactive_timeout = 43200
key_cache_age_threshold = 300
key_cache_block_size = 1024
key_cache_division_limit = 100
lock_wait_timeout = 7200
log_queries_not_using_indexes = OFF
long_query_time = 1.000000
low_priority_updates = OFF
max_allowed_packet = 1G
max_binlog_size = 104857600
max_connect_errors = 2000
max_connections = 4096
max_prepared_stmt_count = 16382
myisam_sort_buffer_size = 4194304
net_buffer_length = 16384
net_read_timeout = 30
net_retry_count = 10
net_write_timeout = 300
query_alloc_block_size = 8192
#query_cache_limit = 1048576
#query_cache_size = 67108864
#query_cache_type = 0
query_prealloc_size = 8192
slow_launch_time = 2
#sort_buffer_size = 6291456
sort_buffer_size = 2M
table_definition_cache = 400
table_open_cache = 10240
myisam_max_sort_file_size=10G  
myisam_sort_buffer_size=2048M
tmp_table_size = 256M
thread_cache_size=10000
open_files_limit = 10240


long_query_time = 10
slow-query-log = on 
slow-query-log-file = /data/dblogs/slow/slow.log
log-bin= /data/dbdata/binlog/mysql-bin
binlog_format = mixed
expire_logs_days = 30
##从库设置
#row从库复制安全,从库主键,复制速度加快
#binlog_format=row
#全局事物ID 便于主从搭建和访问
#gtid-mode=on
#是否强制GTID的一致性
#enforce-gtid-consistency=true
#是否记录从服务器同步数据动作
log_slave_updates=1
#崩溃时保证二进制和服务器安全
#master信息的记录位置 MariaDB没有该参数
#master-info-repository=TABLE
#中继日志信息的记录位置 MariaDB没有该参数
#relay-log-info-repository=TABLE
#启用之后确保无信息丢失
sync-master-info=1
#设置从服务器复制线程数 MariaDB没有该参数
#slave-parallel-workers=8
#启用之可用于在二进制日志记录事件相关的信息,可降低故障排除的复杂度  MariaDB没有该参数
#binlog-rows-query-log-events=1 
#设置binlog校验算法(循环冗余校验码)
binlog-checksum=CRC32 
#设置主服务器是否校验
master-verify-checksum=1
#设置从服务器是否校验
slave-sql-verify-checksum=1

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

编辑于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券