码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2016-01-22 22:17:36      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:mysql主从失败 错误got fatal error 1236解决方法

由于mysql主服务器异外重启, 导致slave maysql server报错, 错误如下:
查看从伺服器错误:
mysql> show slave status\G;
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

Relay_Master_Log_File: mysql-bin.000288日志导出

[root@db1 ~]# mysqlbinlog /data/mysql/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 status\G;
*************************** 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机器.

本文出自 “boyhack” 博客,请务必保留此出处http://461205160.blog.51cto.com/274918/1737721

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

标签:mysql主从失败 错误got fatal error 1236解决方法

原文地址:http://461205160.blog.51cto.com/274918/1737721

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!