主库:10.0.2.75;从库:10.0.2.230;
主库操作:
mysql> show slave status\G;
mysql> flush tables with read lock\G
mysql> show master status\G
mysql> change master to master_host='10.0.2.230', master_user='root', master_password='123456', master_log_file='mysql-bin.000005', master_log_pos=625;
###mater_log_file和master_log_pos的值是在从库上执行show master status\G 的结果
出现报错:
mysql> unlock tables;
mysql> start slave;
出现报错;处理;
mysql> reset slave;
重新配置;
mysql> change master to master_host='10.0.2.230', master_user='root', master_password='123456', master_log_file='mysql-bin.000005', master_log_pos=625;
mysql> start slave;
mysql> show slave status\G;
主库成功;开始配置从库;
mysql> flush tables with read lock\G
mysql> show master status\G
mysql> change master to master_host='10.0.2.75', master_user='root', master_password='123456', master_log_file='mysql-bin.000008', master_log_pos=639208;
###mater_log_file和master_log_pos的值是在主库上执行show master status的结果
mysql> start slave;
mysql> reset slave;
mysql> change master to master_host='10.0.2.75', master_user='root', master_password='123456', master_log_file='mysql-bin.000008', master_log_pos=639208;
mysql> start slave;
mysql> show slave status\G
mysql> UNLOCK TABLES;