两个M主机操作(serverid不能相同)
#打开logbin
log-bin
#设置serverid
server-id=142
#打开gtid功能
gtid_mode=on
#强制数据一致性
enforce_gtid_consistency=1
授权:mysql> grant replication slave,replication client on . to ‘rep’@‘192.168.243.%’ identified by ‘Gy@123456’;
刷新授权:mysql> flush privileges;
找个主机备份数据:mysqldump -p’Gy@123456’ –all-databases –single-transaction –master-data=1 –flush-logs>
date +%F
-mysql-all.sql
拷贝给备机:[root@Server2 ~]# scp 2019-04-25-mysql-all.sql root@192.168.243.140:/root
两个S备机操作(serverid不能相同)
#设置serverid
server-id=142
#打开gtid功能
gtid_mode=on
#强制数据一致性
enforce_gtid_consistency=1
#数据写入表
master-info-repository=TABLE
relay-log-info-repository=TABLE
登录数据库执行reset master清除二进制文件
授权:
change master to master_host=‘master1’,master_user=‘rep’,master_password=‘Gy@123456’,master_auto_position=1 for channel ‘rep-master1’(设置频道名称);
change master to master_host=‘master2’,master_user=‘rep’, master_password=‘Gy@123456’,master_auto_position=1 for channel ‘rep-master2’;
将主上面的二进制文件备份后执行reset master清除
启动slave:start slave;
查看是否正常show slave status;