GTID跳过事务

1.错误原因是因为从库误删数据,再删的主库数据,导致从库找不到主库删除的那条数据

             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 xp.xp; Can't find record in 'xp', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log test4-bin.000003, end_log_pos 2342

2.跳过事务

mysql>  select * from performance_schema.replication_applier_status_by_worker\G
*************************** 1. row ***************************
                                           CHANNEL_NAME:
                                              WORKER_ID: 0
                                              THREAD_ID: NULL
                                          SERVICE_STATE: OFF
                                      LAST_ERROR_NUMBER: 1032
                                     LAST_ERROR_MESSAGE: Could not execute Delete_rows event on table xp.xp; Can't find record in 'xp', Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event's master log test4-bin.000003, end_log_pos 2342
                                   LAST_ERROR_TIMESTAMP: 2023-11-24 14:46:35.916545
                               LAST_APPLIED_TRANSACTION: b0610c84-8a92-11ee-be7e-2a26553b6ba7:11
     LAST_APPLIED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 2023-11-24 14:45:41.094280
    LAST_APPLIED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 2023-11-24 14:45:41.094280
         LAST_APPLIED_TRANSACTION_START_APPLY_TIMESTAMP: 2023-11-24 14:45:40.661198
           LAST_APPLIED_TRANSACTION_END_APPLY_TIMESTAMP: 2023-11-24 14:45:40.663848
                                   APPLYING_TRANSACTION: b0610c84-8a92-11ee-be7e-2a26553b6ba7:12
         APPLYING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP: 2023-11-24 14:46:36.348964
        APPLYING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP: 2023-11-24 14:46:36.348964
             APPLYING_TRANSACTION_START_APPLY_TIMESTAMP: 2023-11-24 14:46:35.916135
                 LAST_APPLIED_TRANSACTION_RETRIES_COUNT: 0
   LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER: 0
  LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE:
LAST_APPLIED_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000
                     APPLYING_TRANSACTION_RETRIES_COUNT: 0
       APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_NUMBER: 0
      APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_MESSAGE:
    APPLYING_TRANSACTION_LAST_TRANSIENT_ERROR_TIMESTAMP: 0000-00-00 00:00:00.000000
1 row in set (0.00 sec)


其中   APPLYING_TRANSACTION: b0610c84-8a92-11ee-be7e-2a26553b6ba7:12  就是我们要跳过的事务

3.跳过事务

mysql> set gtid_next='b0610c84-8a92-11ee-be7e-2a26553b6ba7:12';
Query OK, 0 rows affected (0.00 sec)

mysql> begin; commit;    ## 设置空事件,如果不设置,会重启slave时会报错
Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.00 sec)

mysql> set session gtid_next = automatic;  ##重新获取gtid的事件
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.00 sec)

4.再次查看

	mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 
                  Master_User: slave
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: test4-bin.000003
          Read_Master_Log_Pos: 196
               Relay_Log_File: test1-relay-bin.000004
                Relay_Log_Pos: 411
        Relay_Master_Log_File: test4-bin.000003
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
相关推荐
深圳安锐科技有限公司几秒前
首次接触结构安全自动化监测系统,价格高吗?后期维护?
运维·自动化
冬天vs不冷8 分钟前
Linux用户与权限管理详解
linux·运维·chrome
凯子坚持 c1 小时前
深入Linux权限体系:守护系统安全的第一道防线
linux·运维·系统安全
✿ ༺ ོIT技术༻1 小时前
C++11:新特性&右值引用&移动语义
linux·数据结构·c++
摸鱼也很难4 小时前
Docker 镜像加速和配置的分享 && 云服务器搭建beef-xss
运维·docker·容器
watermelonoops4 小时前
Deepin和Windows传文件(Xftp,WinSCP)
linux·ssh·deepin·winscp·xftp
云和数据.ChenGuang4 小时前
Django 应用安装脚本 – 如何将应用添加到 INSTALLED_APPS 设置中 原创
数据库·django·sqlite
woshilys5 小时前
sql server 查询对象的修改时间
运维·数据库·sqlserver
Hacker_LaoYi5 小时前
SQL注入的那些面试题总结
数据库·sql
疯狂飙车的蜗牛5 小时前
从零玩转CanMV-K230(4)-小核Linux驱动开发参考
linux·运维·驱动开发