Mysql5.7主从数据库同步失败(日记文件错误)解决记录

2023-12-30 07:30:15

记录一次Mysql主从数据库同步失败(日记文件错误)解决记录

查看同步状态:

具体错误:

?检查mysql数据库日记

2021-06-10T03:45:43.522398Z 1 [ERROR] Error reading packet from server for channel '': event read from binlog did not pass crc check; the first event 'mysql-bin.000669' at 1108554596, the last event read from './mysql-bin.000669' at 123, the last byte read from './mysql-bin.000669' at 1108561927. (server_errno=1236)

2021-06-10T03:45:43.522415Z 1 [ERROR] Slave I/O for channel '': Got fatal error 1236 from master when reading data from binary log: 'event read from binlog did not pass crc check; the first event 'mysql-bin.000669' at 1108554596, the last event read from './mysql-bin.000669' at 123, the last byte read from './mysql-bin.000669' at 1108561927.', Error_code: 1236

2021-06-10T03:45:43.522423Z 1 [Note] Slave I/O thread exiting for channel '', read up to log 'mysql-bin.000669', position 1108554596

根据错误日记? 查检binlog文件

mysqlbinlog mysql-bin.000669 --start-position=1108554596 --stop-position=1108561927

另外一种方法查看错误:

?

发现biglog文件损坏,正好是日记文件尾部?

mysqlbinlog -v --start-position=1108554596? mysql-bin.000669

?

?尾部文件损坏,查看下一份日 记文件头部是否正常,如果正常从下一份日记文件开始同步

?

STOP SLAVE;

变更同步文件

CHANGE MASTER TO MASTER_HOST='172.xx.xx.211', MASTER_PORT=3306, MASTER_USER='userName', MASTER_PASSWORD='xxxxxx', MASTER_LOG_FILE='mysql-bin.000670', MASTER_LOG_POS=0;

START SLAVE;

SHOW SLAVE STATUS \G

恢复正常,如下图:

?

mysql主从同步常用到的运维指令:

#查看主从同步状态
SHOW SLAVE STATUS

#允许执行错误的sql数量
SET GLOBAL sql_slave_skip_counter=1

#启动同步
START SLAVE

#停止同步
STOP SLAVE

文章来源:https://blog.csdn.net/qyhua/article/details/135295126
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。