记一次MYSQL主从sql线程not_running故障处理
os:redhat7,DB:mysql 6.7 主从
主从线程未running,同步中断
Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log master-bin.000403, end_log_pos 333202176
根据唯一性key查找相关记录
master库备份记录
slave库删除重复记录
1. 从库操作
show variables like '%slave_exec_mode%';
set global slave_exec_mode='IDEMPOTENT';
stop slave;
start slave;
2. 确认主从无延迟及确认数据一致 操作完后,修改回去-------可以了,改回去(存在数据不一致的风险)
set global slave_exec_mode='STRICT';
stop slave;
start slave;
UPDATE报错:
Could not execute Update_rows event on table skdata_2021.qrtz_scheduler_state; Can't find record in 'qrtz_scheduler_state',
Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log master-bin.000403, end_log_pos 333327330
1. 使用mysqlbinlog主库操作:
▼▼▼
mysqlbinlog --no-defaults --base64-output=decode-rows --verbose --start-position=333326998 --stop-position=333327330 master-bin.000403
把更新前记录找出,并在从库插入执行,再启动slave sql进程
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 333327142
#210628 10:41:19 server id 127 end_log_pos 333327216 CRC32 0xb31a9243 Table_map: `skdata_2021`.`qrtz_scheduler_state` mapped to number 110214
# at 333327216
#210628 10:41:19 server id 127 end_log_pos 333327330 CRC32 0x85a6c09f Update_rows: table id 110214 flags: STMT_END_F
### UPDATE `skdata_2021`.`qrtz_scheduler_state`
### WHERE
### @1='fpskgl21616596076563'
### @2=1624848058505
### @3=20000
### SET
### @1='fpskgl21616596076563'
### @2=1624848078982
### @3=20000
ROLLBACK /* added by mysqlbinlog */ /*!*/;
SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/;
DELIMITER ;
# End of log file
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
▼▼▼
set sql_log_bin=0;
insert into `skdata_2021`.`qrtz_scheduler_state` values ('fpskgl21616596076563',1624848058505,20000);
commit;
set sql_log_bin=1;
▼▼▼
start slave sql_thread;
更多精彩干货分享
点击下方名片关注
IT那活儿