跳過錯誤有兩種方式:
1.跳過指定數量的事務:
mysql>slave stop;
mysql>set global sql_slave_skip_counter=1; #跳過一個事務
mysql>slave start
2.修改mysql的配置文件,通過slave_skip_errors參數來跳所有錯誤或指定類型的錯誤
vi /etc/my.cnf
[mysqld]
slave-skip-errors=1062,1053,1146 #跳過指定error no類型的錯誤
#slave-skip-errors=all #跳過所有錯誤
注意:當配置文件裏寫兩行:
slave-skip-errors=1062
slave-skip-errors=1032時,第二個參數會覆蓋第一個參數。所以一定要寫到同一行,並用逗號分隔。
雖然slave會跳過這些錯誤,繼續複製,但是仍會以Warning的形式記錄到錯誤日誌中,如:
Error_code: 1062
Aug 16 17:44:53 mysql75 mysqld: 2017-08-16T09:44:53.142158Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15616-62' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.910737Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-84' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.911141Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-85' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.911918Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-87' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.912676Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-88' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.913248Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-89' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.913808Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-90' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:44:57 mysql75 mysqld: 2017-08-16T09:44:57.914573Z 2 [Note] Slave SQL for channel '': Could not execute Query event. Detailed error: Duplicate entry '2017-08-14-3002-15626-91' for key 'PRIMARY';, Error_code: 1062
Aug 16 17:46:18 mysql75 mysqld: 2017-08-16T09:46:18.933328Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 15293ms. The settings might not be optimal. (flushed=4427 and evicted=0, during the time.)
Aug 16 17:48:48 mysql75 mysqld: 2017-08-16T09:48:48.759770Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4020ms. The settings might not be optimal. (flushed=4850 and evicted=0, during the time.)
Aug 16 17:49:30 mysql75 mysqld: 2017-08-16T09:49:30.383725Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 4139ms. The settings might not be optimal. (flushed=4984 and evicted=0, during the time.)