共計 1686 個字符,預(yù)計需要花費 5 分鐘才能閱讀完成。
MySQL 斷電出現(xiàn) Error 1236 該怎么辦,很多新手對此不是很清楚,為了幫助大家解決這個難題,下面丸趣 TV 小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
今天幾臺 MySQL 服務(wù)器突然停電,重啟后復(fù)制無法啟動,總是報如下錯誤:
080922 10:29:01 [Note] Slave SQL thread initialized, starting replication in log mysql-bin.000778 at position 2874108, relay log
./relay-bin.003287 position: 2874245
080922 10:29:01 [Note] Slave I/O thread: connected to master replication@192.168.0.10:3306 , replication started in log mysql-b
in.000778 at position 2874108
080922 10:29:01 [ERROR] Error reading packet from server: Client requested master to start replication from impossible position (se
rver_errno=1236)
080922 10:29:01 [ERROR] Got fatal error 1236: Client requested master to start replication from impossible position from master wh
en reading data from binary log
[@more@]
為什么會報 impossible position 呢?打開 mysql-bin.000778 看看。
mysqlbinlog mysql-bin.000778 log.sql
tail -f log.sql
# at 2871574
#080922 10:20:27 server id 2 end_log_pos 2871601 Xid = 2516638
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/
最后一個 position 是 2871574,而從庫要從 2874108 開始,難怪報 impossible position,難道是斷電時有部分 log 在緩存中還沒來得及寫入 binglog?無論如何先恢復(fù)再說吧
stop slave;
CHANGE MASTER TO
MASTER_LOG_FILE= mysql-bin.000778 ,
MASTER_LOG_POS=2871574;
start slave;
show slave statusG
同步正常。。
后來查看主庫的啟動日志中這樣一段
InnoDB: Last MySQL binlog file position 0 2874108, file name ./mysql-bin.000778
080922 10:22:09 InnoDB: Started; log sequence number 6 2534366248
080922 10:22:09 [Note] Recovering after a crash using mysql-bin
080922 10:22:09 [Note] Starting crash recovery…
080922 10:22:09 [Note] Crash recovery finished.
080922 10:22:09 [Note] /usr/sbin/mysqld: ready for connections.
這里 Last MySQL binlog file position 0 2874108 也是錯誤的,這個信息到底是哪里來的呢?為什么會這樣呢?不明白。
為了保證以后 binglog 及時寫入,將主庫 sync_binlog 變量設(shè)置 1。
看完上述內(nèi)容是否對您有幫助呢?如果還想對相關(guān)知識有進(jìn)一步的了解或閱讀更多相關(guān)文章,請關(guān)注丸趣 TV 行業(yè)資訊頻道,感謝您對丸趣 TV 的支持。