mysql进行主主配置:
mysql进行主主配置其实跟主从配置差不多,会主从配置了,就会主主配置了,因为做完主从之后,再给他反过来就是主主了;
如:A是master,B是slave,A到B做主从,反过来B到A做主从,那就是主主同步了。
环境:A 192.168.3.111 B:192.168.2.235
修改A机器的配置文件:
server-id = 1
log-bin = mysql-bin
binlog_format = mixed
log-slave-updates = true
###配置master
relay-log = relay-log-bin
relay-log-index = slave-relay-bin.index
replicate-wild-ignore-table=mysql.% ####在同步的时候排除这个库
##配置slave
进入数据库:
grant replication slave on . to ‘slave’@‘192.168.2.235’ identified by ‘123456’; ##创建一个带有复制权限的slave用户
show master status;
change master to master_host=‘192.168.2.235’,master_user=‘slave’,master_password=‘123456’,master_log_file=‘mysql-bin.000003’,master_log_pos=106;
###这的master_log_file,master_log_pos 应该为B机器上的。
start slave
修改B机器的配置文件:
server-id = 2
relay-log = relay-log-bin
relay-log-index = slave-relay-bin.index
replicate-wild-ignore-table=mysql.%
log-bin = mysql-bin
binlog_format = mixed
log-slave-updates = true
进入数据库:
grant replication slave on . to ‘slave’@‘192.168.3.111’ identified by ‘123456’;
show master status;
change master to master_host=‘192.168.3.111’,master_user=‘slave’,master_password=‘123456’,master_log_file=‘mysql-bin.000003’,master_log_pos=106;
###这的master_log_file,master_log_pos 应该为 A 机器上的。
start slave;
在A和B上执行show slave status\G; 看 Slave_IO_Running 和 Slave_SQL_Running 是否都为yes,都为yes及ok。