標籤:
1.在兩台mysql上建立使用者,設定許可權 A上添加: grant replication slave,replication client,reload,super on *.* to ‘sync_user‘@‘192.168.2.220‘ identified by ‘123456‘ with grant option;//用於B訪問 B上: grant replication slave,replication client,reload,super on *.* to ‘sync_user‘@‘192.168.2.67‘ identified by ‘123456‘ with grant option;//用於A訪問執行 #flush privileges; 更新資料庫使使用者生效。create database testsync;use testsync;create table t_user ( id int primary key auto_increment, username varchar(20), age int);在[mysqld]下面添加以下配置# test synchronized at 67log-binserver-id = 1master-host =192.168.2.220master-user =sync_usermaster-pass =123456master-port =3306master-connect-retry =60replicate-do-db =testsyncreplicate-do-db =testsync2replicate-ignore-db =mysql,information_schema,performance_schemaauto_increment_increment=1# test synchronized at 220log-binserver-id = 2master-host =192.168.2.67master-user =sync_usermaster-pass =123456master-port =3306master-connect-retry =60replicate-do-db =testsyncreplicate-do-db =testsync2replicate-ignore-db =mysql,information_schema,performance_schemaauto_increment_increment=2show processlist;insert into t_user values(null, ‘frank‘, 23);select * from t_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= 1binlog-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=1
http://ylw6006.blog.51cto.com/470441/888523
mysql 雙向同步