程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> MySQL Error 1236 錯誤解決辦法

MySQL Error 1236 錯誤解決辦法

編輯:MySQL綜合教程

在一次不小心電腦突然掉電了,開機開就出來了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

今天幾台MySQL服務器突然停電,重啟後復制無法啟動,總是報如下錯誤:

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 '[email protected]: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

為什麼會報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?無論如何先恢復再說吧

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變量設置1。

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved