CentOS 6.9上安装mysql-5.6.36
1、准备数据存放的文件系统
新建一个逻辑卷,并将其挂载至特定目录即可。这里不再给出过程。
这里假设其逻辑卷的挂载目录为/data,而后需要创建/data/mysqldata目录做为mysql数据的存放目录。
[root@001 /]# mkdir -p /data/mysqldata
2、新建用户以安全方式运行进程:
[root@001 ~]# groupadd -r mysql [root@001 ~]# useradd -g mysql -r -s /sbin/nologin -M -d /data/mysqldata mysql [root@001 ~]# chown -R mysql:mysql /data/mysqldata
3、安装并初始化mysql-5.6.23
首先下载linux64位二进制版本的MySQL5.6至本地,mysql-advanced-5.6.23-linux-glibc2.5-x86_64.tar.gz
[root@001 ~]# tar zxf mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz -C /usr/local/ #根据实际情况修改
[root@001 ~]# cd /usr/local/
[root@001 ~]# ln -sv mysql-5.6.36-linux-glibc2.5-x86_64/ mysql #根据实际情况修改
[root@001 ~]# cd mysql
[root@001 ~]# chown -R mysql:mysql .
4.为mysql提供主配置文件: #默认初始化后会在/etc下有my.cnf,如有内容删除覆盖即可
[root@001 mysql]# vim /etc/my.cnf
########basic settings########
#bind_address = 10.166.224.32 #根据实际情况修改
#autocommit = 0 #5.6.X安装时,需要注释掉,安装完成后再打开
datadir = /data/mysqldata #根据实际情况修改,建议和程序分离存放
transaction_isolation = READ-COMMITTED
explicit_defaults_for_timestamp = 1
read_rnd_buffer_size = 33554432
slow_query_log_file = slow.log
log_queries_not_using_indexes = 1
log_throttle_queries_not_using_indexes = 10
########replication settings########
master_info_repository = TABLE
relay_log_info_repository = TABLE
binlog_gtid_simple_recovery = 1
slave_skip_errors = ddl_exist_errors
########innodb settings########
innodb_buffer_pool_size = 6G #根据实际情况修改,实验环境需改变大小否则会报错
innodb_buffer_pool_instances = 8
innodb_buffer_pool_load_at_startup = 1
innodb_buffer_pool_dump_at_shutdown = 1
innodb_flush_method = O_DIRECT
innodb_file_format = Barracuda
innodb_file_format_max = Barracuda
innodb_log_group_home_dir = /data/mysqldata #根据实际情况修改
innodb_undo_directory = /data/mysqldata #根据实际情况修改
innodb_log_file_size = 4G #根据实际情况修改,实验环境需改小
innodb_log_buffer_size = 16777216
innodb_thread_concurrency = 64
innodb_print_all_deadlocks = 1
innodb_sort_buffer_size = 67108864
########semi sync replication settings########
plugin_dir=/usr/local/mysql/lib/plugin #根据实际情况修改
plugin_load = "rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so"
loose_rpl_semi_sync_master_enabled = 1
loose_rpl_semi_sync_slave_enabled = 1
loose_rpl_semi_sync_master_timeout = 5000
innodb_buffer_pool_dump_pct = 40
innodb_purge_rseg_truncate_frequency = 128
transaction_write_set_extraction=MURMUR32
[root@001 mysql]# scripts/mysql_install_db --user=mysql --datadir=/data/mysqldata/
[root@001 mysql]# chown -R root .
6、修改PATH环境变量,让系统可以直接使用mysql的相关命令。
[root@master ~]# service mysqld start
[root@001 mysql]# chkconfig mysqld on