您的位置:首页 > 数据库 > MySQL

MySQL主从error1236:‘Could not find first log file name in binary log index file’处理#Olivia丶长歌#

2018-02-02 09:33 661 查看
在搭建一个MySQL master-slave集群时,执行了change master命令, start slave 启动主从服务,结果查看salve状态出现报错:mysql> show slave status\G*************************** 1. row ***************************略             Slave_IO_Running: No            Slave_SQL_Running: Yes略 Last_IO_Errno: 1236                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'略************************************************************
首先查看执行的change master命令是否存在空格,如果change master命令没有错误。做如下操作从库停止主从关系mysql>stop slave;主库刷新binlog日志mysql>flush logs;查看binlog和pos号mysql>show master status;例:mysql-bin.000015,pos为120。从库执行命令,使binlog和pos对应主库mysql>change master to master_log_file='mysql-bin.000015',master_log_pos=150;开启主从服务mysql>start slave;查看主从状态mysql>show slave status\G;如果这时的IO线程还为NO,还报error1236,可能是因为主库服务器重启所致,找不到binlog的pos号。或者因为binlog过旧,因为binlog日志默认设置为保留七天。解决方法从库mysql>stop slave;主库切换到binlog日志目录cd /data/mysql/bin/ls找到最后一个binlog为mysql-bin.000053,将binlog重定向到text文件中/usr/local/mysql/bin/mysqlbinlog  mysql-bin.000053>test.txt然后less  test.txt# at 54378#111010 16:35:46 server id 1 end_log_pos 627625631 Query thread_id=45613333exec_time=32758 error_code=0SET TIMESTAMP=1318289746/*!*/;delete from freeshipping_bef_update where part='AR-4006WLM' and code=''/*!*/;# at54580#111010 16:35:46 server id 1 end_log_pos627625751 Query thread_id=45613333exec_time=32758 error_code=0SET TIMESTAMP=1318289746/*!*/;delete from shippingFee_special where part='AR-4006WLM'/*!*/;DELIMITER ;# End of log fileROLLBACK /* added by mysqlbinlog */;/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;找到最接近错误标记的一个position是54580.从库mysql>change master to master_log_file='mysql-bin.000053',master_log_pos=54580;mysql>start slave;mysql>show slave status\G;这时的IO线程和SQL线程应该全部为YES。主从复制服务开启。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySQL主从报错
相关文章推荐