zoukankan      html  css  js  c++  java
  • MySQL主从失败 错误Got fatal error 1236解决方法

    --MySQL主从失败 错误Got fatal error 1236解决方法

    ----------------------------------------------------2014/05/19

    由于主服务器异外重启, 导致从报错, 错误如下:
    show slave status错误:

    mysql> show slave statusG
    Master_Log_File: mysql-bin.000288
    Read_Master_Log_Pos: 627806304
    Relay_Log_File: mysql-relay-bin.000990
    Relay_Log_Pos: 627806457
    Relay_Master_Log_File: mysql-bin.000288
    Slave_IO_Running: No
    Slave_SQL_Running: Yes
    Exec_Master_Log_Pos: 627806304
    Relay_Log_Space: 627806663
    ......
    Last_IO_Error: Got fatal error 1236 from master when  reading data from binary log:
    'Client requested master to start  replication from impossible position'

    mysql错误日志:

    tail /data/mysql/mysql-error.log
    111010 17:35:49 [ERROR] Error reading packet from server: Client requested master
     to start replication from impossible position ( server_errno=1236)
    111010 17:35:49 [ERROR] 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
    111010 17:35:49 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000288',
    position 627806304

    按照习惯, 先尝试必改position位置.

    mysql> stop slave;
    mysql> change master to master_log_file='mysql-bin.000288',master_log_pos=627625751;
    mysql> start slave;

    错误依旧, 接下来登陆到主服务器查看binlog日志.
    先按照错误点的标记去主服务器日志中查找:

    [root@db1 ~]# mysqlbinlog --start-position=627655136 /data/mysql/binlog/mysql-bin.000288
    /*!40019 SET @@session.max_insert_delayed_threads=0*/;
    /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
    DELIMITER /*!*/;
    # at 4
    #111010 13:31:19 server id 4 end_log_pos 106 Start: binlog v 4, server v 5.1.45-log
    created 111010 13:31:19
    # Warning: this binlog is either in use or was not closed properly.
    BINLOG '
    F1aTTg8EAAAAZgAAAGoAAAABAAQANS4xLjQ1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
    '/*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

    没有看到这个位置.

    [root@db1 ~]# mysqlbinlog /data/mysql/binlog/mysql-bin.000288 > test.txt
    
    less text.txt
    看最后一部分
    # at 627625495
    #111010 16:35:46 server id 1 end_log_pos 627625631 Query thread_id=45613333
    exec_time=32758 error_code=0
    SET TIMESTAMP=1318289746/*!*/;
    delete from freeshipping_bef_update where part='AR-4006WLM' and code=''
    /*!*/;
    # at 627625631
    #111010 16:35:46 server id 1 end_log_pos 627625751 Query thread_id=45613333
    exec_time=32758 error_code=0
    SET TIMESTAMP=1318289746/*!*/;
    delete from shippingFee_special where part='AR-4006WLM'
    /*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

    找到最接近错误标记627655136的一个position是627625631.

    再回到slave机器上change master, 将postion指向这个位置.

    mysql> stop slave;
    Query OK, 0 rows affected (0.00 sec)
    
    mysql> change master to master_log_file='mysql-bin.000288',master_log_pos=627625631;
    Query OK, 0 rows affected (0.06 sec)
    
    mysql> start slave;
    Query OK, 0 rows affected (0.00 sec)

    再次查看

    mysql> show slave statusG
    *************************** 1. row ***************************
    Slave_IO_State: Queueing master event to the relay log
    Master_Host: 192.168.21.105
    Master_User: rep
    Master_Port: 3306
    Connect_Retry: 10
    Master_Log_File: mysql-bin.000289
    Read_Master_Log_Pos: 25433767
    Relay_Log_File: mysql-relay-bin.000003
    Relay_Log_Pos: 630
    Relay_Master_Log_File: mysql-bin.000289
    Slave_IO_Running: Yes
    Slave_SQL_Running: Yes

    主从同步正常了, 同样的方法修复其它slave机器.

    今天在机器上面做实验就遇到这个问题,按照上面方法导出binlog观察。

    # at 327
    #140519  7:12:52 server id 1  end_log_pos 457 CRC32 0xcd046be7  Query   thread_id=27    exec_time=0       error_code=0
    SET TIMESTAMP=1400508772/*!*/;
    insert into bin_test values(1,'d'),(2,'d'),(3,'4')
    /*!*/;
    # at 457      --将position改到此处,问题解决。
    #140519  7:12:52 server id 1  end_log_pos 488 CRC32 0xcfa07af8  Xid = 392
    COMMIT/*!*/;
    # at 488
    #140519  7:37:29 server id 1  end_log_pos 573 CRC32 0x6c35fa44  Query   thread_id=29    exec_time=0       error_code=0
    SET TIMESTAMP=1400510249/*!*/;
    BEGIN
    /*!*/;
    # at 573
    #140519  7:37:29 server id 1  end_log_pos 697 CRC32 0x6747d19a  Query   thread_id=29    exec_time=0       error_code=0
    SET TIMESTAMP=1400510249/*!*/;
    insert into bin_test values (777777777,'wi')
    /*!*/;
    # at 697
    #140519  7:37:29 server id 1  end_log_pos 728 CRC32 0x32dde783  Xid = 426
    COMMIT/*!*/;
    DELIMITER ;
    # End of log file
    ROLLBACK /* added by mysqlbinlog */;
    /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
    /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
  • 相关阅读:
    HDU 1170 Balloon Comes!
    深入学习QWidget-1
    UI复习练习_优酷布局
    【IOS】 readonly IOS下实战入门
    Android--推断文本文件编码
    2、应用设置之属性、名词等解析
    QT国际化,中英文等多语言界面显示的方法
    利用Java编写简单的WebService实例
    隐式意图调用系统自带组件的各种Uri总结
    Spring MVC学习-----------springMVC-mvc.xml
  • 原文地址:https://www.cnblogs.com/jackhub/p/3737890.html
Copyright © 2011-2022 走看看