mysql主从不同步问题 Error_code: 1032

1、通过命令查看从库状态mysql> show slave status \G

发现错误

Could not execute Update_rows event on table mysql.user; Can't find record in 'user', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.002339, end_log_pos 1465

错误描述比较明显,在更新 mysql.user表的行时无法更新,缺少更新的记录。

2、去主库找 log mysql-bin.002339  end_log_pos 1465这个点,发现由于时间过长,主库的binlog已经自动清除掉了 (由expire_logs_days参数控制)

3、在从库找到relaylog执行到的点

Relay_Log_File: mysqld-relay-bin.007023
                Relay_Log_Pos: 283

通过mysqlbinlog查看这个点的SQL。

在使用mysqlbinlog是碰到一个问题

ERROR: Error in Log_event::read_log_event(): 'Sanity check failed', data_len: 41, event_type: 30 

ERROR: Could not read entry at offset 1331: Error in log format or read error.

检查版本,发现binlog版本不对,mysql5.6对应的应该是mysqlbinlog 3.4 故应该用3.4版本进行对relaylog的解析

#mysqlbinlog --version

 

mysqlbinlog Ver 3.3 for redhat-linux-gnu at x86_64

#/data/server/mysql-5.6.24/bin/mysqlbinlog --version

/data/server/mysql-5.6.24/bin/mysqlbinlog Ver 3.4 for linux-glibc2.5 at x86_64 

mysql> select @@version;
+-------------------------------------------+
| @@version                                 |
+-------------------------------------------+
| 5.6.24-enterprise-commercial-advanced-log |
+-------------------------------------------+
1 row in set (0.00 sec)
4、最后在relaylog找到 Relay_Log_Pos: 283这个点,发现SQL在对用户进行修改,但从库root用户的host与主库不相符,把从库root用户的host改成与主库一致后,主从就同步了。

 

转载于:https://www.cnblogs.com/Knight7971/p/9915757.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值