MySQL主从失败报错误: Got fatal error 1236

一、问题原因及报错误信息

由于MySQL主库意外重启,导致从库无法同步报错如下:

登录从库查看主从同步的错误信息

[[email protected]192-168-7-101 mysql]# vim mysqld-error.log
2018-12-11 12:57:35 1788 [ERROR] Error reading packet from server: Client requested master to start replication from position > file size; the first event ‘master-bin.002295‘ at 1021866995, the last event read from ‘./master-bin.002295‘ at 4, the last byte read from ‘./master-bin.002295‘ at 4. (server_errno=1236)
2018-12-11 12:57:35 1788 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: ‘Client requested master to start replication from position > file size; the first event ‘master-bin.002295‘ at 1021866995, the last event read from ‘./master-bin.002295‘ at 4, the last byte read from ‘./master-bin.002295‘ at 4.‘, Error_code: 1236
[[email protected]192-168-7-101 mysql]# mysql -u root -pmysql> show slave status \G*************************** 1. row ***************************               Slave_IO_State:                   Master_Host: 192.168.3.230                  Master_User: repl                  Master_Port: 3306                Connect_Retry: 60              Master_Log_File: master-bin.002295          Read_Master_Log_Pos: 1021866995               Relay_Log_File: 192-168-3-236-relay-bin.000001                Relay_Log_Pos: 4        Relay_Master_Log_File: master-bin.002295             Slave_IO_Running: No            Slave_SQL_Running: Yes              Replicate_Do_DB:           Replicate_Ignore_DB:            Replicate_Do_Table:        Replicate_Ignore_Table:       Replicate_Wild_Do_Table:   Replicate_Wild_Ignore_Table:                    Last_Errno: 0                   Last_Error:                  Skip_Counter: 0          Exec_Master_Log_Pos: 1021866995              Relay_Log_Space: 120              Until_Condition: None               Until_Log_File:                 Until_Log_Pos: 0           Master_SSL_Allowed: No           Master_SSL_CA_File:            Master_SSL_CA_Path:               Master_SSL_Cert:             Master_SSL_Cipher:                Master_SSL_Key:         Seconds_Behind_Master: NULLMaster_SSL_Verify_Server_Cert: No                Last_IO_Errno: 1236                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Client requested master to start replication from position > file size; the first event ‘master-bin.002295‘ at 1021866995, the last event read from ‘./master-bin.002295‘ at 4, the last byte read from ‘./master-bin.002295‘ at 4.‘               Last_SQL_Errno: 0               Last_SQL_Error:   Replicate_Ignore_Server_Ids:              Master_Server_Id: 1                  Master_UUID: f7c24af7-a54a-11e6-88b4-525400169c04             Master_Info_File: /Data/work/local/mysql/master.info                    SQL_Delay: 0          SQL_Remaining_Delay: NULL      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it           Master_Retry_Count: 86400                  Master_Bind:       Last_IO_Error_Timestamp: 181211 12:57:35     Last_SQL_Error_Timestamp:                Master_SSL_Crl:            Master_SSL_Crlpath:            Retrieved_Gtid_Set:             Executed_Gtid_Set:                 Auto_Position: 01 row in set (0.00 sec)

二、解决方法

1. 先登录到MySQL主库,搜索后并未找到position的位置

[[email protected]192-168-7-100 mysql]# mysqlbinlog  --no-defaults --start-position=1021866995 master-bin.002295
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @[email protected]@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#181210 22:41:27 server id 1  end_log_pos 120 CRC32 0x1fe77f51     Start: binlog v 4, server v 5.6.30-log created 181210 22:41:27
BINLOG ‘
F3sOXA8BAAAAdAAAAHgAAAAAAAQANS42LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAVF/
5x8=
‘/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET [email protected]_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
2. 解析binlog日志文件,找到离1021866995最近的position最近的位置102186424
[[email protected]192-168-7-100 mysql]# mysqlbinlog  --no-defaults  master-bin.002295 >/root/test.sql[[email protected]192-168-7-100 mysql]# vim /root/test.sql
# at 102186284
#181211  0:05:07 server id 1  end_log_pos 102186315 CRC32 0xd5613884    Xid = 1912388
COMMIT/*!*/;
# at 102186315
#181211  0:05:07 server id 1  end_log_pos 102186392 CRC32 0x2b89095e    Query   thread_id=13545 exec_time=1     error_code=0
SET TIMESTAMP=1544457907/*!*/;
BEGIN
/*!*/;
# at 102186392
# at 102186424

3.登录从库,重新指定主从的同步位置[[email protected]192-168-7-101 mysql]# mysql -u root -p
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> change master to master_log_file=‘master-bin.002295‘,master_log_pos=102186424;
Query OK, 0 rows affected (0.16 sec)

mysql> start slave;
Query OK, 0 rows affected (0.03 sec)

mysql> show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Queueing master event to the relay log
                  Master_Host: 192.168.3.230
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: master-bin.002295
          Read_Master_Log_Pos: 155577520
               Relay_Log_File: 192-168-7.100-relay-bin.000002
                Relay_Log_Pos: 498191
        Relay_Master_Log_File: master-bin.002295
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 102684331
              Relay_Log_Space: 53391561
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master: 46929
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 1
                  Master_UUID: f7c24af7-a54a-11e6-88b4-525400169c04
             Master_Info_File: /Data/work/local/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: updating
           Master_Retry_Count: 86400
                  Master_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Master_SSL_Crl:
           Master_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
1 row in set (0.00 sec)

原文地址:https://www.cnblogs.com/cyleon/p/10101787.html

时间: 2024-11-09 02:15:43

MySQL主从失败报错误: Got fatal error 1236的相关文章

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

由于mysql主服务器异外重启, 导致slave maysql server报错, 错误如下:查看从伺服器错误:mysql> show slave status\G;Master_Log_File: mysql-bin.000288Read_Master_Log_Pos: 627806304Relay_Log_File: mysql-relay-bin.000990Relay_Log_Pos: 627806457Relay_Master_Log_File: mysql-bin.000288Sla

mysql主从同步失败Last_IO_Error: Got fatal error 1236 from master解决方法

mysql教程主从同步失败Last_IO_Error: Got fatal error 1236 from master解决方法 遇到这样的错误如:“Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'”等或由于清数据导致主从库不同步了,解决办法如下: 先进入sl

mysql主从同步失败Last_IO_Error: Got fatal error 1236 from master解决方法

mysql教程主从同步失败Last_IO_Error: Got fatal error 1236 from master解决方法 遇到这样的错误如:“Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'”等或由于清数据导致主从库不同步了,解决办法如下: 先进入sl

mysql 主从 Got fatal error 1236 from master when reading data from binary log: 'Could not find first 错误

本地MySQL环境,是两台MySQL做M-M复制.今天发现错误信息: mysql 5.5.28-log> show slave status\G *************************** 1. row ***************************                Slave_IO_State:                   Master_Host: 88.88.88.88                   Master_User: replicate

mysql从库Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'报错处理

年后回来查看mysql运行状况与备份情况,登录mysql从库查看主从同步状态 1 mysql> show slave status\G; 2 *************************** 1. row *************************** 3 Slave_IO_State: 4 Master_Host: 101.200.*.* 5 Master_User: backup 6 Master_Port: 3306 7 Connect_Retry: 60 8 Master_

VS2010 C++编译报错LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

编译mongodb-src-r2.2.2出现以下问题 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 这个是由于日志文件引起的,可以将 项目\属性\配置属性\清单工具\输入和输出\嵌入清单:原来是“是”,改成“否”. 或者将 项目\属性\配置属性\链接器\清单文件\生成清单:原来是“是”,改成“否”. 如果仍然无效,判断是否已经安装了VS2012,如果已经安装,需要安装VS2010 sp1补丁. VS2010 C++编译报错LINK : fa

配置MySQL主从复制报错Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work

配置MySQL主从复制报错 Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this do

MySQL主从同步报错故障处理记录

前言 在发生故障切换后,经常遇到的问题就是同步报错,下面是最近收集的报错信息. 记录删除失败 在master上删除一条记录,而slave上找不到 Last_SQL_Error: Could not execute Delete_rows event on table hcy.t1; Can't find record in 't1', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysq

【MySQL】Got fatal error 1236原因和解决方法

一 前言  MySQL 的主从复制作为一项高可用特性,用于将主库的数据同步到从库,在维护主从复制数据库集群的时候,作为专职的MySQL DBA,笔者相信大多数人都会遇到"Got fatal error 1236 from master when reading data from binary log" 这类的报错/报警.本文整理了常见的几种 error 1236 报错,并给出相应的解决方法,有所不足之处,当然也希望各位读者朋友指正. 二 常见的error 1236 报错2.1 log