MySQL主从同步异常问题解决Client requested master to start replication from position > file size
MySQL主从同步异常问题解决Client requested master to start replication from position > file size
一、问题描述
MySQL主库服务器内存条异常导致机器频繁重启,替换内存条解决后,发现从库同步状态异常。主从同步已停止。现象如下:
--登录从库服务器,查看从库的数据库状态:
mysql> show slave status\G
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: 'Client requested master to start replication from position > file size; the first event 'master-bin.000824' at 601236980, the last event read from './master-bin.000824' at 4, the last byte read from './master-bin.000824' at 4.'
二、分析解决
1.登录主库服务器,切换到主库的日志目录下
[root@db-001 ~]# cd /data/mysql/data/
[root@db-001 data]#
[root@db-001 data]# mysqlbinlog master-bin.000824 > masterbin000824.log
[root@db-001 data]# tail -f masterbin000824.log
#171206 8:54:08 server id 1 end_log_pos 601220873 CRC32 0x2ebaec99 Xid = 2190302874
end_log_pos 601220873 比 报错提示的601236980小很多,直接从这个点开始重新配置主从
2.登录从库服务器,执行如下操作
mysql> change master to master_host='192.168.1.106',master_port=3306,master_user='repl',master_password='repl',master_log_file='master-bin.000824',master_log_pos=601220873;
3.查看从库状态,发现主从同步已恢复
mysql> show slave status\G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Last_IO_Errno: 0
Last_IO_Error:
判断主从完全同步方式:
首先Master_Log_File和Relay_Master_Log_File所指向的文件必须一致。
其次Relay_Log_Pos和Exec_Master_Log_Pos的为止也要一致才行。