筆記: MySQL replication 問題 Client requested master to start replication from impossible position 解法

今天遇到MySQL的master伺服器主機當機的情況,當master復原時,slaves都出現了

 Slave I/O: Got fatal error 1236 from master when reading data from binary log: ‘Client requested master to start replication from impossible position’, Error_code: 1236

這樣的錯誤,問題起因很簡單,原本的slave正在pulling的master.bin因為當機的原因不正常關閉,當下次master資料庫終於正常重啟時,master會開另一個bin繼續寫,此時slave重練上後不知道有這件事,繼續向master要求當掉的bin的下一筆資料,就會出現上面的錯誤

只要確定是這種情況,解決方法就是看新的bin編號是到多少

mysql> show master statusG
*************************** 1. row ***************************
            File: master-bin.000073
        Position: 21959116
    Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)

把file和位置指向下一個新開的檔案

slave stop;
CHANGE MASTER TO
    MASTER_LOG_FILE='master-bin.000073',
    MASTER_LOG_POS=0
;
slave start;
show slave statusG

如此一來就解決了

參考資料 http://firelitdesign.blogspot.com/2011/04/how-to-fix-mysql-replication-error-1236.html

This entry was posted in 筆記 and tagged , , , , , . Bookmark the permalink.

Comments are closed.