MySQL Error 1236 错误解决办法

木木老贼 互联网营销达人~

在一次不小心电脑突然掉电了,开机开就出来了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服务器突然停电,重启后复制无法启动,总是报如下错误:

  1. 08092210:29:01[Note]SlaveSQLthreadinitialized,startingreplicationinlog'mysql-bin.000778'atposition2874108,relaylog'./relay-bin.003287'position:2874245
  2. 08092210:29:01[Note]SlaveI/Othread:connectedtomaster'replication@192.168.0.10:3306',replicationstartedinlog'mysql-bin.000778'atposition2874108
  3. 08092210:29:01[ERROR]Errorreadingpacketfromserver:Clientrequestedmastertostartreplicationfromimpossibleposition(server_errno=1236)--phpfensi.com
  4. 08092210:29:01[ERROR]Gotfatalerror1236:'Clientrequestedmastertostartreplicationfromimpossibleposition'frommasterwhenreadingdatafrombinarylog

为什么会报impossible position呢?打开mysql-bin.000778看看.

  1. mysqlbinlogmysql-bin.000778>log.sql
  2. tail-flog.sql
  3. #at2871574#08092210:20:27serverid2end_log_pos2871601Xid=2516638
  4. COMMIT/*!*/;
  5. DELIMITER;
  6. #Endoflogfile
  7. ROLLBACK/*addedbymysqlbinlog*/;
  8. /*!50003SETCOMPLETION_TYPE=@OLD_COMPLETION_TYPE*/

最后一个position是2871574,而从库要从2874108开始,难怪报impossible position,难道是断电时有部分log在缓存中还没来得及写入binglog?无论如何先恢复再说吧.

  1. stopslave;
  2. CHANGEMASTERTO
  3. MASTER_LOG_FILE='mysql-bin.000778',
  4. MASTER_LOG_POS=2871574;
  5. startslave;
  6. showslavestatusG

同步正常,后来查看主库的启动日志中这样一段:

  1. InnoDB:LastMySQLbinlogfileposition02874108,filename./mysql-bin.000778
  2. 08092210:22:09InnoDB:Started;logsequencenumber62534366248
  3. 08092210:22:09[Note]Recoveringafteracrashusingmysql-bin
  4. 08092210:22:09[Note]Startingcrashrecovery...
  5. 08092210:22:09[Note]Crashrecoveryfinished.
  6. 08092210:22:09[Note]/usr/sbin/mysqld:readyforconnections.

这里Last MySQL binlog file position 0 2874108也是错误的,这个信息到底是哪里来的呢?为什么会这样呢?不明白,为了保证以后binglog及时写入,将主库sync_binlog变量设置1.

相关广告
  • MySQL Error 1236 错误解决办法 MySQL Error 1236 错误解决办法 MySQL Error 1236 错误解决办法
相关阅读

MySQL Error 1236 错误解决办法

2019/10/10 17:33:01 | 谷歌SEO算法 | 手机网站制作