mysql主主同步

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Linux_newbie_rookie/article/details/79310846
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。

----------------------------------------------------------------------------------------------------------------------------
mysql的主主+keepalived的高可用参考:http://blog.51cto.com/7424593/1741717











没有更多推荐了,返回首页