现象:
在从库上用查看同步状态:
mysql> show slave status\G;
Slave_IO_Running:No
去到主库上:
show master status;查看主库的状态
发现从库上的Master_Log_File和Read_Master_Log_Pos跟主库上不一样
解决方法:
去到主库上:
show master status;查看主库的状态
mysql> flush logs;
Query OK, 0 rows affected (0.44 sec)
mysql> show master status;
±-----------------±---------±-------------±-----------------±------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
±-----------------±---------±-------------±-----------------±------------------+
| mysql-bin.000274 | 120 | | | |
±-----------------±---------±-------------±-----------------±------------------+
1 row in set (0.00 sec)
然后马上回到从库
mysql> slave stop;
mysql> CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000274’,MASTER_LOG_POS=120;
mysql> slave start;
mysql> show slave status\G;
此时在从库中show slave status发现Slave_IO_Running:Yes
表示同步正常;
验证方法:
在主库中增加一个临时表,随便增加几条数据,看能不能同步到从库
衍生问题:
但是此时主库中有些已经存在的数据无法同步过去:
解决方法:
只能将主库中的没同步过去的数据先备份,然后删除,最后再增加一次就能同步到从库了