MySQL主庫服務器內存條異常致使機器頻繁重啓,替換內存條解決後,發現從庫同步狀態異常。主從同步已中止。現象以下: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.'
[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小不少,直接從這個點開始從新配置主從
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;
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的爲止也要一致才行。