遇到Relay log read failure

4月 29th, 2010 | Posted by | Filed under 未分类

本文内容遵从CC版权协议, 可以随意转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明
网址: http://www.penglixun.com/database/relay-log-read-failure.html

今天遇到MySQL服务器报了一个从来没见过的复制错误:
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.

开始以为RelayLog回写的错误,@sky000提醒我是我把数据目录放错了位置,本该是link的地方成了物理目录,本该是物理目录的地方成了link,于是很快耗尽了分区空间。
这么看应该是RelayLog没写全导致错误,重置目录位置后,有了空间重新开始写Relay Log,在没写全的位置读取Relay Log就出错了。

先看看slave复制显示的信息。
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: IP
Master_User: repl
Master_Port: 3306
Connect_Retry: 30
Master_Log_File: mysql-bin.x
Read_Master_Log_Pos: pos_x
Relay_Log_File: relay-bin.y
Relay_Log_Pos: pos_y
Relay_Master_Log_File: mysql-bin.z
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
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: pos_z
Relay_Log_Space: 4132423412
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: 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.
1 row in set (0.00 sec)

没见过这种错误,开始有点慌。然后定神想了想,只要知道已经复制到哪里了,CHANGE MASTER应该是可以解决问题的。
Google发现Relay_Master_Log_File和Exec_Master_Log_Pos参数就是记录执行Master的binlog的位置信息。
于是直接
CHANGE MASTER TO Master_Log_File=’mysql-bin.z’, Master_Log_Pos=pos_z;

重新start slave后正常。