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的為止也要一致才行。
