首页

解决mysql集群报"handler error HA_ERR_KEY_NOT_FOUND...end_log_pos 402, Error_code: 1032"造成主从无法及时同步

标签: ERROR1032,HA_ERR_KEY_NOT_FOUND,slave-skip-errors     发布时间:2019-05-18   

一、异常说明

在安装mysql主从cluster集群时报"[ERROR] Slave SQL for channel : Could not execute Delete_rows event on table mytest.tb_test; Can't find record in 'tb_test', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000006, end_log_pos 402, Error_code: 1032"异常提醒,造成主服务器master新增内容无法正常同步到slave机上,详情如下>>

2019-05-14T12:56:00.409855Z 10 [ERROR] Slave SQL for channel '': Could not execute Delete_rows event on table mytest.tb_test; Can't find record in 'tb_test', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000006, end_log_pos 402, Error_code: 1032@b@2019-05-14T12:56:00.409863Z 10 [Warning] Slave: Can't find record in 'tb_test' Error_code: 1032@b@2019-05-14T12:56:00.409866Z 10 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.000006' position 154.

二、解决方法

方法一、该异常时由于mysql slave备机不存在该记录,但是主机master删除时无需报1032错误,可以通过my.cnf可配置slave-skip-errors=1032 从而跳过日志中1032 ERROR报错

[root@centos-cluster-s19423 ~]# vi  /etc/my.cnf@b@...@b@slave-skip-errors=1032

方法二、登录到mysql进行set global sql_slave_skip_counter=1;  具体如下

[root@centos-cluster-s19423 ~]# mysql  -uroot  -p123456;@b@mysql: [Warning] Using a password on the command line interface can be insecure.@b@Welcome to the MySQL monitor.  Commands end with ; or \g.@b@Your MySQL connection id is 5@b@Server version: 5.7.26-log MySQL Community Server (GPL)@b@@b@Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.@b@@b@Oracle is a registered trademark of Oracle Corporation and/or its@b@affiliates. Other names may be trademarks of their respective@b@owners.@b@@b@Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.@b@@b@mysql> set global sql_slave_skip_counter=1;  @b@Query OK, 0 rows affected (0.00 sec)@b@@b@mysql> stop slave; @b@Query OK, 0 rows affected (0.02 sec)@b@@b@mysql> start slave;@b@Query OK, 0 rows affected (0.00 sec)
  • ◆ 相关内容