gtid 1032错误案例

大致背景:

  分别在主从上删除了系统冗余账号。

mysql> delete from mysql.user where host='::1';
Query OK, 1 row affected (0.01 sec)

mysql> select user,host from mysql.user where host="::1";
Empty set (0.00 sec)

mysql> delete from mysql.user where host='dba\_test\_001';
Query OK, 1 row affected (0.00 sec)

mysql> select user,host from mysql.user where host="::1";

然后就顺利的模拟出了下面的故障。

[root@dba_test_002 ~]# cat error.txt
mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.10.50.60
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000021
          Read_Master_Log_Pos: 1761
               Relay_Log_File: relay-bin.000051
                Relay_Log_Pos: 401
        Relay_Master_Log_File: mysql-bin.000021
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 1032
                   Last_Error: Could not execute Delete_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.000021, end_log_pos 707
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 191
              Relay_Log_Space: 90227450
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1032
               Last_SQL_Error: Could not execute Delete_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.000021, end_log_pos 707
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1574144089
                  Master_UUID: 0501f340-0a94-11ea-ad2b-5254007dcbb3
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State:
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp: 191204 16:11:25
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:10-5440870
            Executed_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:1-5440867,
137347eb-0a94-11ea-ad2b-525400dd43f8:1-531071
                Auto_Position: 0
1 row in set (0.00 sec)

ERROR:
No query specified

mysql>

# 检查主库的日志
 /data/mysql/percona_server/bin/mysqlbinlog -vvv --base64-output-decode=rows  --stop-position=707 mysql-bin.000021 >21.binlog
/data/mysql/percona_server/bin/mysqlbinlog: unknown variable 'default-character-set=utf8mb4'

两个方法可以解决这个问题

一是在MySQL的配置/etc/my.cnf中将default-character-set=utf8 修改为 character-set-server = utf8,但是这需要重启MySQL服务,如果你的MySQL服务正在忙,

那这样的代价会比较大。

二是用mysqlbinlog --no-defaults mysql-bin.000004 命令打开

/data/mysql/percona_server/bin/mysqlbinlog --no-defaults -vvv --base64-output=decode-rows  --stop-position=707 mysql-bin.000021 >21.binlog 
 
# 在解析出来的日志中
SET @@SESSION.GTID_NEXT= '0501f340-0a94-11ea-ad2b-5254007dcbb3:5440868'/*!*/;
# at 239
#191204 15:54:44 server id 1574144089  end_log_pos 307 CRC32 0x9a232d9b         Query   thread_id=1     exec_time=0     error_code=0
SET TIMESTAMP=1575446084/*!*/;
SET @@session.pseudo_thread_id=1/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1073741824/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8mb4 *//*!*/;
SET @@session.character_set_client=224,@@session.collation_connection=224,@@session.collation_server=224/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 307
#191204 15:54:44 server id 1574144089  end_log_pos 476 CRC32 0x226b252a         Table_map: `mysql`.`user` mapped to number 1
# at 476
#191204 15:54:44 server id 1574144089  end_log_pos 707 CRC32 0x5f556bfd         Delete_rows: table id 1 flags: STMT_END_F

SET GTID_NEXT='0501f340-0a94-11ea-ad2b-5254007dcbb3:5440868';

-- 这里的''中的值,不好确定,所以从主库日志中查看,经过验证,是正常的。笔者第一次,还错误的写成了'0501f340-0a94-11ea-ad2b-5254007dcbb3:5440870'

BEGIN;COMMIT;
SET GTID_NEXT='AUTOMATIC';
START SLAVE;
show slave status\G;

# 再次出现异常
mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.10.50.60
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000021
          Read_Master_Log_Pos: 1761
               Relay_Log_File: relay-bin.000051
                Relay_Log_Pos: 986
        Relay_Master_Log_File: mysql-bin.000021
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 1032
                   Last_Error: Could not execute Delete_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.000021, end_log_pos 1194
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 776
              Relay_Log_Space: 90227450
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1032
               Last_SQL_Error: Could not execute Delete_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.000021, end_log_pos 1194
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1574144089
                  Master_UUID: 0501f340-0a94-11ea-ad2b-5254007dcbb3
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State:
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp: 191204 16:40:29
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:10-5440870
            Executed_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:1-5440868:5440870,
137347eb-0a94-11ea-ad2b-525400dd43f8:1-531071
                Auto_Position: 0
1 row in set (0.00 sec)

ERROR:
No query specified

#在日志中找到所需信息
SET @@SESSION.GTID_NEXT= '0501f340-0a94-11ea-ad2b-5254007dcbb3:5440869'/*!*/;
# at 824
#191204 15:55:17 server id 1574144089  end_log_pos 892 CRC32 0x8a128fdd         Query   thread_id=1     exec_time=0     error_code=0
SET TIMESTAMP=1575446117/*!*/;
BEGIN
/*!*/;
# at 892
#191204 15:55:17 server id 1574144089  end_log_pos 1061 CRC32 0x3fe67eeb        Table_map: `mysql`.`user` mapped to number 1
# at 1061
#191204 15:55:17 server id 1574144089  end_log_pos 1194 CRC32 0x1fbd26d1        Delete_rows: table id 1 flags: STMT_END_F

SET GTID_NEXT='0501f340-0a94-11ea-ad2b-5254007dcbb3:5440869';
BEGIN;COMMIT;
SET GTID_NEXT='AUTOMATIC';
START SLAVE;
show slave status\G;

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 10.10.50.60
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000021
          Read_Master_Log_Pos: 1761
               Relay_Log_File: relay-bin.000051
                Relay_Log_Pos: 1971
        Relay_Master_Log_File: mysql-bin.000021
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 1761
              Relay_Log_Space: 90227450
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1574144089
                  Master_UUID: 0501f340-0a94-11ea-ad2b-5254007dcbb3
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:10-5440870
            Executed_Gtid_Set: 0501f340-0a94-11ea-ad2b-5254007dcbb3:1-5440870,
137347eb-0a94-11ea-ad2b-525400dd43f8:1-531071
                Auto_Position: 0
1 row in set (0.00 sec)

[root@dba_test_002 ~]#

重于正常同步了!

gtid 1032错误案例的更多相关文章

  1. MySQL数据库“十宗罪”【十大经典错误案例】

    原文作者:张甦 来源:http://blog.51cto.com/sumongodb 今天就给大家列举 MySQL 数据库中,最经典的十大错误案例,并附有处理问题的解决思路和方法,希望能给刚入行,或数 ...

  2. ORA-07445&ORA-00108错误案例

    由于需要ORACLE的UAT测试环境,克隆了虚拟机后,修改IP地址后,启动实例遇到了ORA-07445 &ORA-00108错误. 案例环境:   SQL> select * from ...

  3. jquery ajax 总是还未等到success回调就刷掉了,就进入了onError函数的错误案例分析

    jquery ajax 总是还未等到success回调就刷掉了,就进入了onError函数的错误案例分析: 同样的请求同时请求了2次,然后第二次的请求把第一次的给刷掉了! (比如:<div on ...

  4. expdp错误案例

    转自:https://www.cnblogs.com/kerrycode/p/3960328.html Oracle数据泵(Data Dump)使用过程当中经常会遇到一些奇奇怪怪的错误案例,下面总结一 ...

  5. cocos2dx 3.1从零学习(四)——内存管理(错误案例分析)

    本篇内容文字比較较多,可是这些都是建立在前面三章写代码特别是传值的时候崩溃的基础上的.可能表达的跟正确的机制有出入,还请指正. 假设有不理解的能够联系我.大家能够讨论一下,共同学习. 首先明白一个事实 ...

  6. http500:服务器内部错误案例详解(服务器代码语法错误或者逻辑错误)

    http500:服务器内部错误案例详解(服务器代码语法错误或者逻辑错误) 一.总结 服务器内部错误可能是服务器中代码运行的时候的语法错误或者逻辑错误 二.http500:服务器内部错误案例详解 只是一 ...

  7. gtid 1032同步异常处理

    gtid  1032同步异常处理 .sql # 在从库中执行 ; ,); ,); ,); ,); ; mysql> select * from fudao_student_lable; +--- ...

  8. MySQL GTID 主从复制错误修复方法

    https://yq.aliyun.com/articles/155827?spm=5176.8067842.tagmain.6.RFPTAL MySQL 传统的主从复制方式使用 master_log ...

  9. MySQL数据库的10大经典错误案例

    学习任何一门技术的同时,其实就是自我修炼的过程.沉下心,尝试去拥抱数据的世界! 案例一 Too many connections (连接数过多,导致连接不上数据库,业务无法正常进行) 问题还原: 解决 ...

随机推荐

  1. 记日杂-log4net组件使用

    下面我给大家介绍一下记日杂-log4net组件使用,当程序发布有服务器上,有时出现了错误, 都不知道出现在那,所以log4net组件很好解决这个问题. 1.添加开发包,并对log4net.dll的引用 ...

  2. Kafka如何实现每秒上百万的高并发写入

    Kafka是高吞吐低延迟的高并发.高性能的消息中间件,在大数据领域有极为广泛的运用.配置良好的Kafka集群甚至可以做到每秒几十万.上百万的超高并发写入. 那么Kafka到底是如何做到这么高的吞吐量和 ...

  3. Minimum Cut(2015沈阳online)【贪心】

    Minimum Cut[贪心]2015沈阳online 题意:割最少的边使得图不连通,并且割掉的边中有且仅有一条是生成树的边. 首先,我们选择一条树中的边进行切割,此时仅考虑树上的边集,有两种情况:1 ...

  4. SOSdp

    layout: post title: SOSdp author: "luowentaoaa" catalog: true tags: mathjax: true - codefo ...

  5. python中property属性的介绍及其应用

    Python的property属性的功能是:property属性内部进行一系列的逻辑计算,最终将计算结果返回. 使用property修饰的实例方法被调用时,可以把它当做实例属性一样 property的 ...

  6. oracle修改TNSLSNR的端口

    oracle 服务一启动 TNSLSNR.exe 会占用8080端口,这时,如果我们其他程序需要使用8080端口就会比较麻烦,所以需要改一下端口: 用dba账户登录 CMD>sqlplus sy ...

  7. “007~ASP 0104~不允许操作”错误的解决方法(图解)

    今天测试一个Z-Blog程序的上传文件时发现总提示“ 007~ASP 0104~不允许操作 ”的错误,经过度度上各位朋友的帮忙,终于找到解决方法. 这是windows2003 server对上传文件的 ...

  8. WCF寄宿windows服务一

    如果只是寄宿单个wcf服务,方法很简单,步骤:1.创建好一个windows服务.关于windows服务内容见:http://www.cnblogs.com/zhaow/p/7866916.html2. ...

  9. vue移动端出现遮罩层时在遮罩层滑动时禁止遮罩层下方页面滑动

    h5页面 点击出现弹框时 在遮罩层上面滑动时 下方的页面会出现滑动现象 解决方法 我知道的有以下两种 在遮罩层标签上添加@touchmove.prevent 把遮罩层显示时把下方的父盒子css设置为固 ...

  10. 简单的todolist的demo

    放上代码: <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF ...