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.000338' at 2507433, the last event read from './master-bin.000338' at 4, the last byte read from './master-bin.000338' at 4.'
查询slave同步状态:
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 10.45.140.90
Master_User: root
Master_Port: 63306
Connect_Retry: 60
Master_Log_File: master-bin.000338
Read_Master_Log_Pos: 2507433
Relay_Log_File: mysql2-relay-bin.000330
Relay_Log_Pos: 2507597
Relay_Master_Log_File: master-bin.000338
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB: bigdata,callphone,case,commondata,cuiji,daixinlianwechat,dxt,golddb,grade,information_schema,mysql,op,payment,performance_schenma,preloantask,pybbs-springboot,schedue_job,statistics,task,user,useraction,zhudaiuser,zwy
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 2507433
Relay_Log_Space: 2507637
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
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.000338' at 2507433, the last event read from './master-bin.000338' at 4, the last byte read from './master-bin.000338' at 4.'
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: b39cd9b1-15cf-11e7-a66b-00163e30c794
Master_Info_File: /data/mysqldb/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp: 191219 13:52:09
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
在主Mysql中查询对应的binlog日志,发现最后at 值为2372686
[root@mysql mysqldb]# mysqlbinlog master-bin.000338 > d.txt
#191219 13:35:21 server id 1 end_log_pos 2372286 CRC32 0x1a36f4be Xid = 278812863
COMMIT/*!*/;
# at 2372286
#191219 13:35:23 server id 1 end_log_pos 2372369 CRC32 0x0da6c0d5 Query thread_id=34436 exec_time=0 error_code=0
SET TIMESTAMP=1576733723/*!*/;
BEGIN
/*!*/;
# at 2372369
# at 2372401
#191219 13:35:23 server id 1 end_log_pos 2372401 CRC32 0x9bb17e5d Intvar
SET INSERT_ID=43782/*!*/;
#191219 13:35:23 server id 1 end_log_pos 2372655 CRC32 0x30637b1d Query thread_id=34436 exec_time=0 error_code=0
use `golddb`/*!*/;
SET TIMESTAMP=1576733723/*!*/;
INSERT INTO sms_receiver (REPORTTIME,PSWD,MSGID,MOBILE,STATUS,ID,RECEIVER) VALUES ( '193111335','null','12138956','111300','SGIP:21',null,'null' )
/*!*/;
# at 2372655
#191219 13:35:23 server id 1 end_log_pos 2372686 CRC32 0x05f3711f Xid = 278813775
COMMIT/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
"d.txt" 105779L, 3172705C
停止Mysql slave服务并重新配置启动
mysql> stop slave;
mysql> change master to master_host='10.30.54.221',master_user='root',master_port=63306,master_password='JhS2ffx2yZYm',master_log_file='master-bin.000339',master_log_pos=4;
Query OK, 0 rows affected, 2 warnings (0.02 sec)
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)
查看同步状态
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.30.54.221
Master_User: root
Master_Port: 63306
Connect_Retry: 60
Master_Log_File: master-bin.000339
Read_Master_Log_Pos: 694142227
Relay_Log_File: mysql2-relay-bin.000002
Relay_Log_Pos: 242038
Relay_Master_Log_File: master-bin.000339
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: bigdata,callphone,case,commondata,cuiji,daixinlianwechat,dxt,golddb,grade,information_schema,mysql,op,payment,performance_schenma,preloantask,pybbs-springboot,schedue_job,statistics,task,user,useraction,zhudaiuser,zwy
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 241874
Relay_Log_Space: 694142565
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 9487990
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: b39cd9b1-15cf-11e7-a66b-00163e30c794
Master_Info_File: /data/mysqldb/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: freeing items
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
报错原因为slave取的at值大于binlog的at值导致报错