Test environment: 192.168.1.192 192.168.1.193 mysql5.2 Configuration 192 server: /usr/local/mysql/bin /mysql-uroot-p Authorization: grant replication Slave,file on * * to ' xm1 ' @ ' 192.168.1.193 ' identified by ' 100200 '; Refresh: flu SH privileges; Configuration 193 server: /usr/local/mysql/bin/mysql-uroot-p authorization: grant replication Slave,file on * * to ' xm2 ' @ ' 192.168.1.192 ' identified by ' 100200 '; refresh: flush privileges; stop two server MySQL service: /etc/ Init.d/mysqld stop Next Configure the My.cnf file for both servers: (Turn on binary log) vi/etc/my.cnf 192 server: User = mysqllog-bin= Mysql-binserver-id = 1binlog-do-db=testbinlog-ignore-db=mysqlreplicate-do-db=testreplicate-ignore-db= Mysqllog-slave-updatesslave-skip-errors=allskip-name-resolvesync_binlog=1auto_increment_increment=2auto_ increment_offset=1 193 server: User = Mysqllog-bin=mysql-binserver-id = 2binlog-do-db=testbinlog-ignore-db= Mysqlreplicate-do-db=testreplicate-ignore-db=mysqllog-slave-updatesslave-skip-errors=allskip-name-resolvesync_ Binlog=1auto_increment_increment=2auto_increment_offset=2 simultaneous start of MySQL service: /etc/init.d/mysqld start Perform the same operation at 192 and 193: /usr/local/mysql/bin/mysqld_safe & after entering Mysql /usr/local/mysql/bin/mysql- uroot-p 192 server: flush tables with read Lock\g show Master status\g 193 server: flush Tables with read Lock; show master status\g backup data. Unlock: unlock TABLES; stop Slave slave stop; perform the change MASTER to command on 192.193 of the two servers. 192:change Master to master_host= ' 192.168.1.193 ', master_user= ' xm2 ', master_password= ' 100200 ', master_log_file= ' mysql-bin.000070 ', Master_log_pos=106;193:change master to master_host= ' 192.168.1.192 ', master_user= ' xm1 ', master_ Password= ' 100200 ', master_log_file= ' mysql-bin.000067 ', Master_log_pos=106; 192:show processlist\g193:show Processlist\g 192:showdatabases;use test;show tables; 193:showdatabases;use test;show tables; This is followed by the process of testing creating 192:create table Table1 to two databases respectively; Switch to 193:show tables;193:create table table2; switch to 192:show tables; can see the database, prove the master configuration is OK!
MySQL Database Master synchronization configuration steps