MySQL主從複製中斷處理一例

來源:互聯網
上載者:User

標籤:

收到mysql主從中斷警示郵件,馬上登上伺服器查看,發現是中繼日誌損壞。 

 

 

Show slave status\G,提示中繼日誌損壞,按以往的做法,根據提示重新指定合適的記錄檔以及pos點。

 Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master‘s binary log is corrupted (you can check this by running ‘mysqlbinlog‘ on the binary log), the slave‘s relay log is corrupted (you can check this by running ‘mysqlbinlog‘ on the relay log), a network problem, or a bug in the master‘s or slave‘s MySQL code. If you want to check the master‘s binary log or slave‘s relay log, you will be able to know their names by issuing ‘SHOW SLAVE STATUS‘ on this slave.

2.  從MySQL5.5.X版本開始,增加了relay_log_recovery參數,這個參數的作用是:當slave從庫宕機後,假如relay-log損壞了,導致一部分中繼日誌沒有處理,則自動放棄所有未執行的relay-log,並且重新從master上擷取日誌,這個參數是預設關閉的。做主從的時候沒有開啟這項參數。修改my.cnf,添加這兩項。(skip-slave-start ,mysql服務啟動跳過自動啟動主從複製,以免產生新的問題),relay_log_recovery不支援動態修改。所以修改設定檔,重啟MySQL服務。

 

#####my.cnf加這兩項                   
relay_log_recovery = 1 

skip-slave-start = 1

###################### 

 

 

3.再查看Show slavestatus\G,同步已經恢複,正在應用中繼日誌,等同步完成之後,然後隨機抽查一個表,資料一致

 

 

 #########################################################

            Relay_Master_Log_File: mysql-bin.000642
            Slave_IO_Running: Yes
            Slave_SQL_Running: Yes

##############################################

            Master_SSL_Key: 
            Seconds_Behind_Master: 0
            Master_SSL_Verify_Server_Cert: No
            Last_IO_Errno: 0
            Last_IO_Error: 
            Last_SQL_Errno: 0
            Last_SQL_Error:

MySQL主從複製中斷處理一例

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.