標籤:os io for 檔案 ar art 問題 sp on
最近MySQL 遇到了同步問題,現整理一下常遇到的錯誤的解決方案,備用。
方法一:手動設定動態參數 sql_slave_skip_counter
我常用的指令碼:
stop slave sql_thread;set global sql_slave_skip_counter=1;start slave sql_thread;
這個要 根據具體的錯誤來判定,一般用於主鍵衝突或者更新失敗錯誤,進行手動跳過。
方法二:靜態伺服器設定,需要重啟MySQL
[mysqld]
slave_skip_errors=1032,1064
重啟MySQL之後,會自動載入設定檔,同步自動跳過更新,與主鍵衝突錯誤。
參數說明:
Normally, replication stops when an error occurs on the slave.
This gives you the opportunity to resolve the inconsistency in the data manually.
This variable tells the slave SQL thread to continue replication when a statement returns any of the errors listed in the variable value.
方法三:動態設定跳過錯誤
slave_exec_mode
這個比較狠
set global slave_exec_mode =strict;
嚴格執行策略。大多數情況下遇到錯誤,同步就會終止。等待錯誤解決。
set global slave_exec_mode =idempotent;
這個設定,可以允許同步跳過
duplicate-key and no-key-found錯誤
參數說明:
Controls whether IDEMPOTENT or STRICT mode is used in replication conflict resolution and error checking.
IDEMPOTENT mode causes suppression of some errors, including duplicate-key and no-key-found errors. Beginning with MySQL 5.1.23-ndb-6.2.14 and MySQL 5.1.24, this mode should be employed in multi-master replication, circular replication, and some other special replication scenarios.
STRICT mode is the default, and is suitable for most other cases
MySQL 跳過同步錯誤方法