mysql主主

server1,server2
grant replication slave on *.* to 'backup'@'192.168.1.%' identified by '123456';
flush privileges;

server1
server-id = 1 
log-bin = /data0/mysql/3306/binlog/binlog
binlog-do-db = test
binlog-ignore-db = mysql
log-slave-updates
sync_binlog=1
auto_increment_offset = 1
auto_increment_increment = 2
replicate-do-db = test
replicate-ignore-db = mysql,information_schema


server2
server-id = 2
log-bin = /data0/mysql/3306/binlog/binlog
replicate-do-db = test
replicate-ignore-db = mysql,information_schema
binlog-do-db = test
binlog-ignore-db = mysql
log-slave-updates
sync_binlog = 1
auto_increment_offset = 2
auto_increment_increment = 2

/data0/mysql/3306/mysql restart

server1
stop slave;
flush tables with read lock;
show master status;
unlock tables;

server2
stop slave;
show master status;

server1
change master to master_host='192.168.1.201', master_user='backup', master_password='123456', master_log_file='binlog.000002', master_log_pos=107;

server2
change master to master_host='192.168.1.202', master_user='backup', master_password='123456', master_log_file='binlog.000002', master_log_pos=107;

server1 server2
start slave;
show slave status\G;
 

你可能感兴趣的:(mysql,主主)