mysql之slave_skip_errors選項

來源:互聯網
上載者:User

標籤:blog   http   os   io   使用   ar   檔案   資料   2014   

要說slave_skip_errors選項,就不得不提mysql的replication機制,總的來說它分了三步來實現mysql主從庫的同步

  1. master將改變記錄到二進位日誌(binary log)中(這些記錄叫做二進位日誌事件,binary log events);
  2. slave將master的binary log events拷貝到它的中繼日誌(relay log);
  3. 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選項

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.