mysql 备库 1032_mysql主从不同步问题 Error_code: 1032
1、通过命令查看从库状态mysql> show slave status G
发现错误
Could not execute Update_rows event on table mysql.user; Cant find record in user, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the events 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改成与主库一致后,主从就同步了。
1、通过命令查看从库状态mysql> show slave status G 发现错误 Could not execute Update_rows event on table mysql.user; Cant find record in user, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the events 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改成与主库一致后,主从就同步了。