时间:2021-07-01 10:21:17 帮助过:3人阅读
1. 配置对应主服务器的信息(这时对应的主服务器为原来的从机即ip为192.168.0.101的服务器)
mysql> change master to master_host=‘192.168.0.105‘,master_user=‘mysync‘,master_ password=‘q123456‘, master_log_file=‘mysql-bin.000003‘,master_log_pos=341; Query OK, 0 rows affected, 2 warnings (0.91 sec)
2. 启动从属进程
mysql> start slave; Query OK, 0 rows affected (0.09 sec) mysql> start slave; Query OK, 0 rows affected (0.09 sec) mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.105 Master_User: mysync Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000003 Read_Master_Log_Pos: 341 Relay_Log_File: user-PC-relay-bin.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000003 Slave_IO_Running: Yes Slave_SQL_Running: Yes
最后使用show slave status命令查看Slave_IO_Running和Slave_SQL_RunningG两个字段的值都为YES即表示配置成功。
备注:
最后貌似还要在原来的从机现在主机上再次配置对应主机的信息才行,即重新执行以下命令
mysql> change master to master_host=‘192.168.0.101‘,master_user=‘mysync‘,master_ password=‘q123456‘, master_log_file=‘mysql-bin.000001‘,master_log_pos=341; Query OK, 0 rows affected, 2 warnings (0.91 sec)
然后还需要再次重启slave进程才行,否则在原来主机上的操作不会同步到从机上来。
mysql主主同步配置
标签: