2.在my.ini上进行相关配置
在[mysqld]下方增加:
A:
server-id = 1
replicate-do-db =mydb
replicate-ignore-db=mysql
log-bin=mysql-bin
expire_logs_day=1
max_binlog_size = 500M
slave-skip-errors=all
skip-name-resolve
max_connect_errors=9999999999
slave_net_timeout=60
wait_timeout=30
innodb_file_per_table=on
back_log=200
B:
server-id = 2
replicate-do-db =mydb
replicate-ignore-db=mysql
log-bin=mysql-bin
expire_logs_day=1
max_binlog_size = 500M
slave-skip-errors=all
skip-name-resolve
max_connect_errors=9999999999
slave_net_timeout=60
wait_timeout=30
innodb_file_per_table=on
back_log=200
保存后,重启mysql
1.jpg (35.02 KB, 下载次数: 4)
2012-2-10 08:45 上传
然后执行:
CHANGE MASTER TO MASTER_HOST='1.1.1.1', MASTER_PORT=3306, MASTER_USER='sync_user', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=1465;
start slave;//开始同步
step3,执行show slave status\G; 如果显示以下信息,表示同步设置成功.
Slave_IO_State: Waiting for master to send event
Slave_IO_Running: Yes Slave_SQL_Running: Yes
step4:上一步没有问题。则在B上继续执行show master status;
#show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000005 | 6854 | | |
+------------------+----------+--------------+------------------+1 row in set (0.00 sec)
step5:在A上执行:stop slave;//停止同步
CHANGE MASTER TO MASTER_HOST='2.2.2.2', MASTER_PORT=3306, MASTER_USER='sync_user', MASTER_PASSWORD='123456', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;
#start slave;//开始同步
step6:执行show slave status\G;如显示如下内容,表示同步设置成功。
Slave_IO_State: Waiting for master to send event
Slave_IO_Running: Yes
Slave_SQL_Running: Yes