查看叢庫狀態show slave statusg
從庫原文提示:Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction ‘864e6992-0a34-11e7-a98a-7cd30ac6c9ec:148408’ at master log mysql-bin.000010, end_log_pos 920578920. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.
1、? 按照叢庫的提示找原因,輸入命令
select?*?from?performance_schema.replication_applier_status_by_workerG
得到
知道這個事務發生在表 r_com_patent 上,定位到表,但是不知道哪一條記錄。
2、? 到主庫找二進制文件發生了什么事。輸入命令
mysqlbinlog?--no-defaults?–v?–v?--base64-output=decode-rows?/usr/local/mysql/data/master-bin.000010?|?grep?–A?‘10’?920578920
終于定位到記錄了。
主庫在表r_com_patent做了更新操作,而叢庫找不到更新的記錄。
具體來說就是,主庫將表r_com_patent中patent_id為45的記錄,字段cid從NULL更改為3253026.而叢庫表r_com_patent中patent_id為45的記錄,字段cid原本為3253026,由于復制機制就必須找叢庫表r_com_patent中patent_id為45并且id為NULL的記錄,所以沒找到。。。
3、? 解決方法
1)???????? 在master查看那條記錄。
Select?*?from?r_com_patent?where?patent_id?=?45;
2)???????? 在slave上,查找下更新后的那條記錄,應該是不存在的。
Select?*?from?r_com_patent?where?patent_id?=?45;
3)???????? 把丟失的數據在Slave上填補或是修改。
Insert?into?r_com_patent?values(3253026,45);
4)???????? 在slave跳過報錯的事務。
Stop?slave; Set?@@SESSION.GTID_NEXT=’?864e6992-0a34-11e7-a98a-7cd30ac6c9ec:148408’ Begin; Commit; Set?@@SESSION.GTID_NEXT?=?AUTOMATIC; Start?slave;
之后,再檢查一遍
Show?slave?statusG
?