博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL主从失败报错误: Got fatal error 1236
阅读量:6495 次
发布时间:2019-06-24

本文共 6971 字,大约阅读时间需要 23 分钟。

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

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

登录从库查看主从同步的错误信息 [root@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
[root@192-168-7-101 mysql]# mysql -u root -p mysql> 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: NULL Master_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: 0 1 row in set (0.00 sec)

二、解决方法

1. 先登录到MySQL主库,搜索后并未找到position的位置 [root@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 @OLD_COMPLETION_TYPE=@@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:27BINLOG 'F3sOXA8BAAAAdAAAAHgAAAAAAAQANS42LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAVF/5x8='/*!*/;DELIMITER ;# End of log fileROLLBACK /* added by mysqlbinlog */;/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 2. 解析binlog日志文件,找到离1021866995最近的position最近的位置102186424 [root@192-168-7-100 mysql]# mysqlbinlog  --no-defaults  master-bin.002295 >/root/test.sql [root@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 = 1912388COMMIT/*!*/;# at 102186315#181211  0:05:07 server id 1  end_log_pos 102186392 CRC32 0x2b89095e    Query   thread_id=13545 exec_time=1     error_code=0SET TIMESTAMP=1544457907/*!*/;BEGIN/*!*/;# at 102186392# at 1021864243.登录从库,重新指定主从的同步位置 [root@192-168-7-101 mysql]# mysql -u root -pmysql> 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: 46929Master_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: 01 row in set (0.00 sec)

 

转载于:https://www.cnblogs.com/cyleon/p/10101787.html

你可能感兴趣的文章
安装 ssh 的公开密匙到 iPhone 上
查看>>
JavaScript 事件冒泡简介及应用(转)
查看>>
为什么VC经常输出烫烫烫烫烫烫烫烫
查看>>
HDU 1412 ( {A} + {B} )
查看>>
Linux常用压缩解压命令
查看>>
Access外键 级联更新、删除
查看>>
mass Framework event模块 v4
查看>>
郑州公积金
查看>>
开发中新游戏《庞加莱》
查看>>
MATLAB 向量
查看>>
MVC3+EF4.1学习系列(一)-------创建EF4.1 code first的第一个实例(强转)
查看>>
JavaMail 邮件发送
查看>>
centos下安装apache + subversion(转)
查看>>
tomcat报 Context [] startup failed due toprevious errors
查看>>
人际心理学
查看>>
系统设计与架构笔记:ETL工具开发和设计的建议
查看>>
Android UI Button 和GridView 的设计--优化(2)
查看>>
Android之解析Android Map地图返回的Json数据
查看>>
超大磁盘分区工具parted使用介绍(一)
查看>>
数据还原到指定时间点的处理示例
查看>>