標籤:blog http os io 使用 ar 檔案 資料 2014
要說slave_skip_errors選項,就不得不提mysql的replication機制,總的來說它分了三步來實現mysql主從庫的同步
- master將改變記錄到二進位日誌(binary log)中(這些記錄叫做二進位日誌事件,binary log events);
- slave將master的binary log events拷貝到它的中繼日誌(relay log);
- slave重做中繼日誌中的事件,將改變反映它自己的資料。
但是在主從同步中會出現因為從庫執行某些sql語句失敗而導致主從備份關係失效,如果要修複這種失效就需要用到slave_skip_errors參數(使用sql_skip_errors_counter也是可以的)。
slave_skip_errors選項有四個可用值,分別為:off、all、ErorCode、ddl_exist_errors。
根據各個值得字面意思即可知道它們的用法,但是其中ddl_exist_errors值卻比較特別,它代表了一組errorCode的組合,分別是:
1007:資料庫已存在,建立資料庫失敗
1008:資料庫不存在,刪除資料庫失敗
1050:資料表已存在,建立資料表失敗
1050:資料表不存在,刪除資料表失敗
1054:欄位不存在,或程式檔案跟資料庫有衝突
1060:欄位重複,導致無法插入
1061:重複鍵名
1068:定義了多個主鍵
1094:位置線程ID
1146:資料表缺失,請恢複資料庫
但是還要注意的是,該值只在mysql cluster版的mysqld中才可用,而在mysql Server版的mysqld中不可用。
用到的文章:
如何查看bin-log內容:http://blog.chinaunix.net/uid-16844903-id-3896711.html
mysql主從同步原理:http://machael.blog.51cto.com/829462/239112/
mysql設定檔說明:http://www.educity.cn/shujuku/1095729.html
mysql小誤區:http://dinglin.iteye.com/blog/1236330
mysql複製的幾種模式:http://www.cnblogs.com/end/archive/2012/12/05/2803975.html
參考:
mysql錯誤碼:http://dev.mysql.com/doc/refman/5.1/en/error-messages-server.html
mysql bugs之關於ddl_exist_errors值:http://i.cnblogs.com/EditPosts.aspx?opt=1
擴充閱讀:
replication常用架構:http://www.cnblogs.com/ggjucheng/archive/2012/11/13/2768879.html
理解mysql 複製(replication):http://www.cnblogs.com/hustcat/archive/2009/12/19/1627525.html
mysql之slave_skip_errors選項