5.6 GTID 启用情况下, 从库跳过一个事物的方法 sql_slave_skip_counter 失效.

来源:这里教程网 时间:2026-03-01 12:01:46 作者:

5.6 数据库报错了.    

从库 报错了,之前 现在从库上删除了一条垃圾表, 

然后在主库上 删除了 垃圾表, 然后从库报错. 

           Last_IO_Errno: 0

                Last_IO_Error: 

               Last_SQL_Errno: 1051

               Last_SQL_Error: Error 'Unknown table 'yq_user_reg_invit_bak20160222'' on query. 

Default database: ''. Query: 'DROP TABLE `yq_user_reg_invit_bak20160222` /* generated by server */'

  Replicate_Ignore_Server_Ids: 

             Master_Server_Id: 110

                  Master_UUID: dfd7a18d-a9aa-11exxxxxxxxxxxxxxxxxxxxxx

             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: 190304 16:19:05

               Master_SSL_Crl: 

           Master_SSL_Crlpath: 

           Retrieved_Gtid_Set: dfd7a18d-a9aa-11e8-afe5-40f2e99dd7d2:1-256481574

            Executed_Gtid_Set: a29497dd-afe8-11e8-9898-40f2e9dc3512:1-2,

dfd7a18d-a9aa-11e8-afe5-40f2e99dd7d2:1-256461742

                Auto_Position: 1

1 row in set (0.00 sec)

stop  slave 以后   执行   sql_slave_skip_counter  + 1  之后 , 不管用了. 

mysql.youqianhua.sock@(none)> set global sql_slave_skip_counter=1 ;

ERROR 1858 (HY000): sql_slave_skip_counter can not be set when the server is running with @@GLOBAL.GTID_MODE = ON. Instead, for each transaction that you want to skip, generate an empty transaction with the same GTID as the transaction

那么新的方案就要跟上了.  

stop  slave;

set   gtid_next='dfd7a18d-a9aa-11e8-afe5-40f2e99dd7d2:256461743' ; 

begin;

commit;

SET gtid_next = 'AUTOMATIC';

start slave ; 

根据 指示 操作就行了.   注意 gtid 跟  show  slave  status 中输出的  next gtid 的写法的差异  + 1  了. 

相关推荐