Centos 7安装mysql group replication总结

配置/etc/hosts
172.27.129.2 mysql-ha-s1
172.27.129.3 mysql-ha-s2
172.27.129.4 mysql-ha-s3

#关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
firewall-cmd --state
 
#关闭selinux
/usr/sbin/sestatus -v
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config


安装mysql 5.7.19

yum localinstall -y https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql-community-server

往/etc/my.cnf文件中加入以下配置
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

#以下为跟组复制相关配置
# base config
server_id=1 #1,2,3
gtid_mode=ON
user=mysql
enforce_gtid_consistency=ON
master_info_repository=TABLE
relay_log_info_repository=TABLE
binlog_checksum=NONE
log_slave_updates=ON
log_bin=binlog
binlog_format=ROW
 
# group replication
transaction_write_set_extraction=XXHASH64
loose-group_replication_group_name="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
loose-group_replication_start_on_boot=off
loose-group_replication_local_address= "172.27.129.2:24901" #修改为当前服务器ip
loose-group_replication_group_seeds= "172.27.129.2:24901,172.27.129.3:24901,172.27.129.4:24901"
loose-group_replication_bootstrap_group= off
 
# open mutil_mode config
loose-group_replication_single_primary_mode=FALSE  #单主/多主 模式
loose-group_replication_enforce_update_everywhere_checks= TRUE

启动mysql
service mysqld start

获取初始密码
cat /var/log/mysqld.log | grep 'temporary password'

登录
mysql -uroot -p

#修改密码
mysql> SET PASSWORD = PASSWORD('Test@123');
mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
mysql> flush privileges;

#卸载密码校验插件
mysql> uninstall plugin validate_password;


mysql-ha-s1服务器,初始化与安装启动group-replication
SET SQL_LOG_BIN=0;
CREATE USER rpl_user@'%';
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF;
#查询启动状态
SELECT * FROM performance_schema.replication_group_members;


#mysql-ha-s2和mysql-ha-s3安装
 
注:全程参照s1安装,有以下几点存在改变。
 
1、注意my.cnf的server_id 顺延变为2和3
2、注意my.cnf的loose-group_replication_local_address顺延
3、mysql初始化与启动脚本按照如下操作:
SET SQL_LOG_BIN=0;
CREATE USER rpl_user@'%';
GRANT REPLICATION SLAVE ON *.* TO rpl_user@'%' IDENTIFIED BY 'rpl_pass';
FLUSH PRIVILEGES;
SET SQL_LOG_BIN=1;
CHANGE MASTER TO MASTER_USER='rpl_user', MASTER_PASSWORD='rpl_pass' FOR CHANNEL 'group_replication_recovery';
INSTALL PLUGIN group_replication SONAME 'group_replication.so';
set global group_replication_allow_local_disjoint_gtids_join=ON;
START GROUP_REPLICATION;
 
其他没有区别。
安装完成,进行测试即可。 


参考文章:
http://www.cnblogs.com/liujian001/p/7687610.html

Leave a Reply

Your email address will not be published. Required fields are marked *