1. Modify it on the basis of MySQL master/slave:
#master1上
[Mysqld]
server-id=101
L Og-bin = Mysql-bin
Auto-increment-increment = 2
auto-increment-offset =
#master2上
[Mysqld]
server-id=103
Log-bin = Mysql-bin
Auto-increment-increment = 2
auto-increment-offset = 1001
2, respectively for two master to create a variety of users for each other's use
#master1的机器上mysql> CREATE USER ‘master1‘@‘%‘ IDENTIFIED BY ‘123456‘;#master2的机器上mysql> CREATE USER ‘master2‘@‘%‘ IDENTIFIED BY ‘123456‘;
3. Grant replication permissions to users individually
#master1的机器上mysql > GRANT REPLICATION SLAVE on *.< Span class= "Hljs-subst" >* to ' Master1 ' @ '% ' identified by ' 123456 '; #master2的机器上mysql > GRANT REPLICATION SLAVE on *. * to ' master2 ' @ '% ' identified by ' 123456 ';
4, restart the service separately, through show master status to view the binary file name and POS location, to configure the replication location for slave
5. Switch master Separately, note Master_log_file and Master_log_pos
#master1的机器上
mysql> Change Master to master_host=' 192.168.137.103 ', master_user=' Master2 ', master_password=' 123456 ', master_log_file=' mysql-bin.000003 ', master_log_pos=951;
#master2的机器上
< Span class= "hljs-string" >mysql> change Master to Master_host= ' 192.168.137.101 ', Master_user= ' Master1 ', master _password= ' 123456 ', Master_log_file= ' mysql-bin.000004 ', Master_log_pos=698;
6. Then start the verification:
Start slave
Ok!!!!!!!
MySQL Main master Building