1. Create a user on two MySQL, set permissions on a add: Grant Replication Slave,replication client,reload,super on*. * To'Sync_user'@'192.168.2.220'Identified by'123456'with GRANT option;//for b accessB: Grant replication slave,replication client,reload,super on*. * To'Sync_user'@'192.168.2.67'Identified by'123456'with GRANT option;//for a accessexecute #flush privileges; Update the database to take effect for the user. Create DATABASE Testsync;use testsync;create table T_user (IDintprimary key auto_increment, username varchar ( -), ageint), add the following configuration under [mysqld] # test synchronized at theLog-Binserver-id =1Master-host =192.168.2.220Master-user =Sync_usermaster-pass =123456Master-port =3306Master-connect-retry = -Replicate- Do-db =testsyncreplicate- Do-db =testsync2replicate-ignore-db =mysql,information_schema,performance_schemaauto_increment_increment=1# test Synchronized at -Log-Binserver-id =2Master-host =192.168.2.67Master-user =Sync_usermaster-pass =123456Master-port =3306Master-connect-retry = -Replicate- Do-db =testsyncreplicate- Do-db =testsync2replicate-ignore-db =mysql,information_schema,performance_schemaauto_increment_increment=2show Processlist;insert into t_user values (NULL,'Frank', at);Select* fromT_user;server-id=2Binlog- Do-db=Happybinlog- Do-db=ipaddressmgrreplicate- Do-db=happyreplicate- Do-db=ipaddressmgrreplicate-ignore-db=Mysql,information_schema,performance_schemalog-slave-Updatesslave-skip-errors=Allsync_binlog=1auto_increment_increment=2Auto_increment_offset=2
log-binserver -id= 1 binlog -do -db=happybinlog - Span style= "color: #0000ff;" >do -db=ipaddressmgrreplicate -do -db=happyreplicate -do -db=< Span style= "color: #000000;" >ipaddressmgrreplicate -ignore-db=mysql,information_schema,performance_ Schemalog -slave-updatesslave -skip-errors= allsync_binlog =1 auto_increment_increment =auto_increment_offset =1
http://ylw6006.blog.51cto.com/470441/888523
MySQL Bidirectional synchronization