linux上mysql的gtid主從複製報錯處理
阿新 • • 發佈:2019-01-01
一、從庫上報錯檢視: show slave status\G Retrieved_Gtid_Set: e10c75be-5c1b-11e6-ab7c-000c296078ae:5-6 #6是出錯的事務 Executed_Gtid_Set: e10c75be-5c1b-11e6-ab7c-000c296078ae:1-5 #已執行過的事務 Auto_Position: 1
二、解決1:單個跳過事務
通過設定gtid_next跳過這個出錯的事務(只能跳過一個事務)
mysql> set gtid_next='e10c75be-5c1b-11e6-ab7c-000c296078ae:6';
mysql> begin;
mysql> commit;
mysql> set gtid_next='AUTOMATIC';
mysql> start slave;
三、解決2:批量的跳過事務 通過設定gtid_purged完成批量跳過事務 1:主庫操作(檢視主庫上已執行的事務) mysql> show master status; +---------------+----------+--------------+------------------+-------------------------------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +---------------+----------+--------------+------------------+-------------------------------------------+ | binlog.000001 | 2364 | | | e10c75be-5c1b-11e6-ab7c-000c296078ae:1-10 | +---------------+----------+--------------+------------------+-------------------------------------------+ 1 row in set (0.00 sec) 從庫上操作: 也可檢視從庫上已執行的事務,mysql> show master status; mysql> reset master; mysql> set GLOBAL gtid_purged='e10c75be-5c1b-11e6-ab7c-000c296078ae:1-10'; mysql> start slave;
四、快照恢復從庫資料 https://mp.csdn.net/postedit/85238158 從庫上操作:做好快照後,檢視sql檔案 cat db.sql | grep GTID_PURGED SET @@GLOBAL.GTID_PURGED='e10c75be-5c1b-11e6-ab7c-000c296078ae:1-10'; mysql> reset master; 再匯入sql檔案 mysql> change master to master_host='主庫ip', master_user='repl', master_password='repl', master_auto_position=1; mysql> start slave;