mysql复制使用gtid,用gtid_purged跳过事务

mysql复制使用gtid,用gtid_purged跳过事务

show slave status查看slave状态时,SQL线程停止运行,错误显示Update错误,如果没有使用gtid,可以使用sql_slave_skip_counter跳过,但是开启gtid后,使用该方式是无效的。

    
  1. root@[(none)] 05:36:24> show slave status\G;
  2. *************************** 1. row ***************************
  3.                Slave_IO_State: Waiting for master to send event
  4.                   Master_Host: 10.1.8.24
  5.                   Master_User: repl
  6.                   Master_Port: 3306
  7.                 Connect_Retry: 60
  8.               Master_Log_File: mysql-bin.000009
  9.           Read_Master_Log_Pos: 49413140
  10.                Relay_Log_File: mysqld-relay-bin.000011
  11.                 Relay_Log_Pos: 2043387
  12.         Relay_Master_Log_File: mysql-bin.000002
  13.              Slave_IO_Running: Yes
  14.             Slave_SQL_Running: No
  15.               Replicate_Do_DB: 
  16.           Replicate_Ignore_DB: 
  17.            Replicate_Do_Table: 
  18.        Replicate_Ignore_Table: 
  19.       Replicate_Wild_Do_Table: zabbix.%
  20.   Replicate_Wild_Ignore_Table: 
  21.                    Last_Errno: 1032
  22.                    Last_Error: Could not execute Update_rows event on table zabbix.user_history; Can't find record in 'user_history', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000002, end_log_pos 28739818
  23.                  Skip_Counter: 0
  24.           Exec_Master_Log_Pos: 28739081
  25.               Relay_Log_Space: 783475657
  26.               Until_Condition: None
  27.                Until_Log_File: 
  28.                 Until_Log_Pos: 0
  29.            Master_SSL_Allowed: No
  30.            Master_SSL_CA_File: 
  31.            Master_SSL_CA_Path: 
  32.               Master_SSL_Cert: 
  33.             Master_SSL_Cipher: 
  34.                Master_SSL_Key: 
  35.         Seconds_Behind_Master: NULL
  36. Master_SSL_Verify_Server_Cert: No
  37.                 Last_IO_Errno: 0
  38.                 Last_IO_Error: 
  39.                Last_SQL_Errno: 1032
  40.                Last_SQL_Error: Could not execute Update_rows event on table zabbix.user_history; Can't find record in 'user_history', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql-bin.000002, end_log_pos 28739818
  41.   Replicate_Ignore_Server_Ids: 
  42.              Master_Server_Id: 1
  43.                   Master_UUID: 7bdd3156-ff10-11e3-91dc-001018a0b030
  44.              Master_Info_File: /var/lib/mysql/master.info
  45.                     SQL_Delay: 0
  46.           SQL_Remaining_Delay: NULL
  47.       Slave_SQL_Running_State: 
  48.            Master_Retry_Count: 86400
  49.                   Master_Bind: 
  50.       Last_IO_Error_Timestamp: 
  51.      Last_SQL_Error_Timestamp: 140928 05:33:17
  52.                Master_SSL_Crl: 
  53.            Master_SSL_Crlpath: 
  54.            Retrieved_Gtid_Set: 7bdd3156-ff10-11e3-91dc-001018a0b030:1-732546
  55.             Executed_Gtid_Set: 7bdd3156-ff10-11e3-91dc-001018a0b030:1-107805 #当前slave执行到的位置
  56.                 Auto_Position: 1
  57. 1 row in set (0.00 sec)
  58. ERROR: 
  59. No query specified


解决办法:

使用
gtid_purged跳过事务,从上面slave状态信息可知,slave当前执行到了
7bdd3156-ff10-11e3-91dc-001018a0b030:1-107805,使用gtid_purged跳过下一个事务
7bdd3156-ff10-11e3-91dc-001018a0b030:1-107806

    
  1. root@[(none)] 05:36:29> stop slave;
  2. Query OK, 0 rows affected (0.05 sec)
  3. root@[(none)] 05:36:35> reset master;
  4. Query OK, 0 rows affected (0.14 sec)
  5. root@[(none)] 05:36:38> set global gtid_purged='7bdd3156-ff10-11e3-91dc-001018a0b030:1-107806'; #跳过事务
  6. Query OK, 0 rows affected (0.13 sec)


查看状态已经恢复正常:
    
  1. root@[(none)] 05:36:57> start slave;show slave status\G;
  2. Query OK, 0 rows affected (0.04 sec)
  3. *************************** 1. row ***************************
  4.                Slave_IO_State: Checking master version
  5.                   Master_Host: 10.1.8.24
  6.                   Master_User: repl
  7.                   Master_Port: 3306
  8.                 Connect_Retry: 60
  9.               Master_Log_File: mysql-bin.000009
  10.           Read_Master_Log_Pos: 49436416
  11.                Relay_Log_File: mysqld-relay-bin.000011
  12.                 Relay_Log_Pos: 2043387
  13.         Relay_Master_Log_File: mysql-bin.000002
  14.              Slave_IO_Running: Yes
  15.             Slave_SQL_Running: Yes
  16.               Replicate_Do_DB: 
  17.           Replicate_Ignore_DB: 
  18.            Replicate_Do_Table: 
  19.        Replicate_Ignore_Table: 
  20.       Replicate_Wild_Do_Table: zabbix.%
  21.   Replicate_Wild_Ignore_Table: 
  22.                    Last_Errno: 0
  23.                    Last_Error: 
  24.                  Skip_Counter: 0
  25.           Exec_Master_Log_Pos: 28739081
  26.               Relay_Log_Space: 783498933
  27.               Until_Condition: None
  28.                Until_Log_File: 
  29.                 Until_Log_Pos: 0
  30.            Master_SSL_Allowed: No
  31.            Master_SSL_CA_File: 
  32.            Master_SSL_CA_Path: 
  33.               Master_SSL_Cert: 
  34.             Master_SSL_Cipher: 
  35.                Master_SSL_Key: 
  36.         Seconds_Behind_Master: 256354
  37. Master_SSL_Verify_Server_Cert: No
  38.                 Last_IO_Errno: 0
  39.                 Last_IO_Error: 
  40.                Last_SQL_Errno: 0
  41.                Last_SQL_Error: 
  42.   Replicate_Ignore_Server_Ids: 
  43.              Master_Server_Id: 1
  44.                   Master_UUID: 7bdd3156-ff10-11e3-91dc-001018a0b030
  45.              Master_Info_File: /var/lib/mysql/master.info
  46.                     SQL_Delay: 0
  47.           SQL_Remaining_Delay: NULL
  48.       Slave_SQL_Running_State: Waiting for the next event in relay log
  49.            Master_Retry_Count: 86400
  50.                   Master_Bind: 
  51.       Last_IO_Error_Timestamp: 
  52.      Last_SQL_Error_Timestamp: 
  53.                Master_SSL_Crl: 
  54.            Master_SSL_Crlpath: 
  55.            Retrieved_Gtid_Set: 7bdd3156-ff10-11e3-91dc-001018a0b030:1-732563
  56.             Executed_Gtid_Set: 7bdd3156-ff10-11e3-91dc-001018a0b030:1-107806
  57.                 Auto_Position: 1
  58. 1 row in set (0.00 sec)
  59. ERROR: 
  60. No query specified


转载于:https://my.oschina.net/anthonyyau/blog/322760

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/109717.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 可变参数列表

    可变参数列表

    2021年10月31日
    44
  • Qt配置OpenCV教程,亲测已试过(详细版)[通俗易懂]

    Qt配置OpenCV教程,亲测已试过(详细版)[通俗易懂]win10系统Qt5.12.9配置OpenCV4.5.1库教程Qt,OpenCV,Cmake详细下载安装教程软件准备首先要说的是装软件还是装最新的好,不用考虑各种软件的版本对应问题,都是最新版的情况下它们互相之间一定是兼容的,下边具体来说下需要的几个软件。64位win10系统Qt5.12.9Cmake3.18.0OpenCV4.5.1以下叙述顺序即为安装配置顺序QtDownload国

    2022年10月4日
    3
  • 西门子SCL定时器_西门子plc断开延时定时器

    西门子SCL定时器_西门子plc断开延时定时器在西门子PLC中利用STEP7软件编程的时候,想实现延时接通功能,通常会用到S_ODT定时器,因为这个最简单。在SCL中同样可以也将这个简单的延时接通定时器使用上,只不过没有像在LAD梯形图中编程那么简单了,稍微繁复了一些,当然这只是我个人意见。还是来看一下我的做法吧,如下图:该图片是SCL建立的源文件,编译后将会生成一个FC1的程序块。图中可以看到我定义了4个输入变量,2个输出变量,以及一个临时变量。可以看到最后编译的结果是0错误0警告!…

    2022年9月26日
    2
  • navicate15激活码【在线破解激活】

    navicate15激活码【在线破解激活】,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月16日
    52
  • JAVA解析XML格式字符串「建议收藏」

    JAVA解析XML格式字符串「建议收藏」importjava.io.IOException;importjava.io.StringReader;importjava.util.List;importorg.jdom.Document;importorg.jdom.Element;importorg.jdom.JDOMException;importorg.jdom.Namespace;im

    2022年5月27日
    31
  • 大数据计算框架有哪些_高中物理知识框架图

    大数据计算框架有哪些_高中物理知识框架图前言大家好,我是土哥写文章整整五个月了,在这期间写了很多篇高质量文章,每一篇都在1000+阅读以上,为了让各位小伙伴更好的学习和面试,我将自己发表的文章以及未发表的文章全部汇总成一个文档,里面包含了全部的无水印高清图片,具体内容如下:关注公众号:【3分钟秒懂大数据】,回复关键字:【大数据】,进群领取下文全部PDF文件。1、大数据学习路线文章硬不硬核,你说了算,土哥怒肝大数据学习路线一条龙!(万字长文+资源分享)上述文章将所有组件的安装包全部都收集好,版本

    2025年7月31日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号