故障现象 :MySQL slave所在机器自动重启,启动MySQL后,查看主从信息如下:
Error_code: 1594
mysql> show slave status \G*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 172.21.101.10 Master_User: repl Master_Port: 3307 Connect_Retry: 60 Master_Log_File: mysql-bin.039177 Read_Master_Log_Pos: 116425042 Relay_Log_File: relay-bin.002356 Relay_Log_Pos: 86299739 Relay_Master_Log_File: mysql-bin.039175 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: mysql.%,information_schema.% Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1594 Last_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave. Skip_Counter: 0 Exec_Master_Log_Pos: 86299576 Relay_Log_Space: 384592256 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: NULLMaster_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1594 Last_SQL_Error: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave. Replicate_Ignore_Server_Ids: Master_Server_Id: 1380 Master_UUID: 5a25a829-f343-11e4-89f3-984be105150c Master_Info_File: /mysqlData/up24/data/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 170328 07:45:56 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0
查看Error log :
2017-03-28 07:29:24 30851 [Note] Slave I/O thread: connected to master 'repl@172.21.101.10:3307',replication started in log 'mysql-bin.039175' at position 87578145
2017-03-28 07:29:24 30851 [Warning] Slave SQL: If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
2017-03-28 07:29:24 30851 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.039175' at position 45009340, relay log './relay-bin.002356' position: 45009503
2017-03-28 07:29:47 30851 [ERROR] Error in Log_event::read_log_event(): 'read error', data_len: 8174, event_type: 32
2017-03-28 07:29:47 30851 [ERROR] Error reading relay log event: slave SQL thread aborted because of I/O error
2017-03-28 07:29:47 30851 [ERROR] Slave SQL: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's MySQL code. If you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'SHOW SLAVE STATUS' on this slave. Error_code: 1594
2017-03-28 07:29:47 30851 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'mysql-bin.039175' position 86299576
解决方法:
根据errorlog的提示,重新设置主从
stop slave ;
change master to master_host='172.21.101.10',master_port=3307,master_user='repl',master_password='repl',master_log_file='mysql-bin.039175', master_log_pos=86299576;
start slave;
show slave status\G 查看状态:恢复正常