Mysql从库GTID跳过错误方法

来自Linux78|wiki

未开启GTID的处理:

set global sql_slave_skip_counter=1;

如果开启了GTID,则会报错:

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

处理参考:

解析二进制日志,找出gtid点

mysqlbinlog --no-defaults mysqlbin.000002 > bin.sql
或通过下述sql查出:
select * from performance_schema.replication_applier_status_by_worker where LAST_ERROR_NUMBER=1032;
1032为show SLAVE STATUS ; 查出的Last_Errno;

跳过报错gtid点,如果有多个,重复执行,注意不要搞错了!!

stop slave ;
set @@session.gtid_next='uuid';
begin;
commit;
set @@session.gtid_next=automatic;
start slave;