標籤:
收到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主從複製中斷處理一例