环境101、102、103三台主机实行主主复制
101配置
#101,101是102的主,也是103的从服务器
#修改配置文件
vim /etc/my.cnf
#server-id=11
#log-bin=master-bin
#log-slave-updates=true
#binlog-format=MIXED
#relay-log=relay-log-bin
#relay-log-index=slave-relay-bin.index
#以上注释是my.cnf添加的内容
#重启
systemctl restart mysqld
#进入mysql
mysql -uroot -ppwd123
#授权
grant replication slave on *.* to 'myslave'@'192.168.10.%' identified by '123456' ;
#更新权限
flush privileges;
#查看主服务器的状态
show master status;
#master-bin.000001,603要通过show master status查看出来的写
change master master_host='192.168.10.103',master_user='myslave',master_password='123456',master_log_file='master-bin.000001',master_log_pos=603;
#开启
start slave;
#查看是否开启
show master slave\G
#测试
create database t1;
102配置
#102,102是103的主,也是101的从服务器
#修改配置文件
vim /etc/my.cnf
#server-id=22
#log-bin=master-bin
#log-slave-updates=true
#binlog-format=MIXED
#relay-log=relay-log-bin
#relay-log-index=slave-relay-bin.index
#以上注释是my.cnf添加的内容
#重启
systemctl restart mysqld
#进入mysql
mysql -uroot -ppwd123
#授权
grant replication slave on *.* to 'myslave'@'192.168.10.%' identified by '123456' ;
#更新权限
flush privileges;
#查看主服务器的状态
show master status;
#master-bin.000001,603要通过show master status查看出来的写
change master master_host='192.168.10.101',master_user='myslave',master_password='123456',master_log_file='master-bin.000001',master_log_pos=603;
#开启
start slave;
#查看是否开启
show master slave\G
#测试
create database t2;
103配置
#103,103是101的主,也是102的从服务器
#修改配置文件
vim /etc/my.cnf
#server-id=33
#log-bin=master-bin
#log-slave-updates=true
#binlog-format=MIXED
#relay-log=relay-log-bin
#relay-log-index=slave-relay-bin.index
#以上注释是my.cnf添加的内容
#重启
systemctl restart mysqld
#进入mysql
mysql -uroot -ppwd123
#授权
grant replication slave on *.* to 'myslave'@'192.168.10.%' identified by '123456' ;
#更新权限
flush privileges;
#查看主服务器的状态
show master status;
#master-bin.000001,603要通过show master status查看出来的写
change master master_host='192.168.10.102',master_user='myslave',master_password='123456',master_log_file='master-bin.000001',master_log_pos=603;
#开启
start slave;
#查看是否开启
show master slave\G
#测试
create database t3;