MySQL 主从复制:二进制日志已清除,错误 1236。可以恢复复制吗?

时间:2021-01-13 12:25:44

标签: mysql mariadb database-replication

场景如下:

MySQL 主服务器正在写入以下二进制日志文件:pccodb22-binlog.000677

奴隶正在读取这个文件。主服务器在冬天关闭,pccodb22-binlog.000677因到期而被清除。

现在,所有从服务器复制失败,出现以下 IO 错误:Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'

我知道奴隶们已经了解了 pccodb22-binlog.000677 中的最新情况。

master 中有几个新的二进制日志:

pccodb22-binlog.000678
pccodb22-binlog.000679
pccodb22-binlog.000680

如何在不破坏复制同步的情况下使从站保持最新状态?

我是这样想的:

STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='pccodb22-binlog.000678', MASTER_LOG_POS=4;
START SLAVE;
#wait for the slave to reach the end of this binlog
STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='pccodb22-binlog.000679', MASTER_LOG_POS=4;
START SLAVE;
#wait for the slave to reach the end of this binlog
STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='pccodb22-binlog.000680', MASTER_LOG_POS=4;
START SLAVE;

或者,以下就够了吗?

STOP SLAVE;
CHANGE MASTER TO MASTER_LOG_FILE='pccodb22-binlog.000678', MASTER_LOG_POS=4;
START SLAVE;

0 个答案:

没有答案
相关问题