从已经提供的报错信息来看,在relay log日志中没有获取到对应的position位置。
1、从binlog日志中发现:"ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 87, event_type: 2" 根据报错的提示来看:在binlog日志中发现了无效的事件,然后rollback。从主库的binlog看起来,个人感觉:好像是通过mysqlbinlog命令解析binlog导入导致,但是mysqlbinlog 命令没能正确解析binlog日志。这种情况可能发生在低版本解析高版本产生binlog日志。你是否通过mysqlbinlog 解析binlog进行导入操作呢? 如果有这种操作的话,尽量先把它解析成sql,看看是否正确,再导入。按照通常的情况来看,这种情况导致主从复制失败的可能性也较小。
2、或者主库突然宕机过?导致binlog日志异常? 这种概率个人感觉很小。
3、如果可能的话,尽量发下M/S的error log 这样便于更准确的查找原因。 作者: chinafenghao 时间: 2013-09-02 09:49 @leo_gongzj
思考可能的问题。
1、你在脚本和命令行使用的命令差异,比如有没使用use db,或者update schema.table.
2、是不是使用了Replicate_Wild_Ignore_db或者Replicate_Do_DB之类的配置。
3、同步出问题是报什么错误.作者: yqhenry 时间: 2013-09-02 10:38
关于这个问题,最好是把报错贴出来比较好排错。如果按照以往的经验来看,我碰到过一次是由于我使用了Replicate_ignore_DB参数导致的。。在使用它的时候,我们需要注意我们所使用的sql语句。在执行操作时,是使用use database 然后再进行操作,还是直接 操作 database.table 如果是后者的话,可能导致主从不同步。要么取消主库中的Replicate_ignore_DB之类参数,要么就配置Replicate_Wild_Ignore_db这种类型的参数取代Replicate_ignore_DB这类参数。作者: leo_gongzj 时间: 2013-09-02 20:44
补充错误日志:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: *.*.*.*
Master_User: slave
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: binlog.000050
Read_Master_Log_Pos: 193
Relay_Log_File: relaylog.000006
Relay_Log_Pos: 248
Relay_Master_Log_File: binlog.000050
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: 106
Relay_Log_Space: 483
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)
ERROR:
No query specified
binlog 日志:
[root@meng522 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/binlog/binlog.000049
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:31:37 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:31:37 at startup
ROLLBACK/*!*/;
BINLOG '
KYUkUg8BAAAAZgAAAGoAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAphSRSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#130902 20:36:55 server id 1 end_log_pos 125 Stop
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
[root@meng522 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/binlog/binlog.000050
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:37:04 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:37:04 at startup
# Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
ROLLBACK/*!*/;
BINLOG '
cIYkUg8BAAAAZgAAAGoAAAABAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABwhiRSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 87, event_type: 2
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
relay日志:
[root@meng520 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/relaylog/relaylog.000006
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:38:01 server id 2 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:38:01
BINLOG '
qYYkUg8CAAAAZgAAAGoAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#700101 8:00:00 server id 1 end_log_pos 0 Rotate to binlog.000050 pos: 106
# at 146
#130902 20:37:04 server id 1 end_log_pos 0 Start: binlog v 4, server v 5.1.33-log created 130902 20:37:04
BINLOG '
cIYkUg8BAAAAZgAAAAAAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 87, event_type: 2
ERROR: Could not read entry at offset 248: Error in log format or read error.
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;作者: leo_gongzj 时间: 2013-09-02 20:45 回复 3# yqhenry
补充错误日志:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: *.*.*.*
Master_User: slave
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: binlog.000050
Read_Master_Log_Pos: 193
Relay_Log_File: relaylog.000006
Relay_Log_Pos: 248
Relay_Master_Log_File: binlog.000050
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: 106
Relay_Log_Space: 483
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)
ERROR:
No query specified
binlog 日志:
[root@meng522 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/binlog/binlog.000049
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:31:37 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:31:37 at startup
ROLLBACK/*!*/;
BINLOG '
KYUkUg8BAAAAZgAAAGoAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAphSRSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#130902 20:36:55 server id 1 end_log_pos 125 Stop
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
[root@meng522 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/binlog/binlog.000050
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:37:04 server id 1 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:37:04 at startup
# Warning: this binlog was not closed properly. Most probably mysqld crashed writing it.
ROLLBACK/*!*/;
BINLOG '
cIYkUg8BAAAAZgAAAGoAAAABAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAABwhiRSEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 87, event_type: 2
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
relay日志:
[root@meng520 mysql]# /usr/local/services/mysql/bin/mysqlbinlog /data/mysql/relaylog/relaylog.000006
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#130902 20:38:01 server id 2 end_log_pos 106 Start: binlog v 4, server v 5.1.33-log created 130902 20:38:01
BINLOG '
qYYkUg8CAAAAZgAAAGoAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
#700101 8:00:00 server id 1 end_log_pos 0 Rotate to binlog.000050 pos: 106
# at 146
#130902 20:37:04 server id 1 end_log_pos 0 Start: binlog v 4, server v 5.1.33-log created 130902 20:37:04
BINLOG '
cIYkUg8BAAAAZgAAAAAAAAAAAAQANS4xLjMzLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
ERROR: Error in Log_event::read_log_event(): 'Found invalid event in binary log', data_len: 87, event_type: 2
ERROR: Could not read entry at offset 248: Error in log format or read error.
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;作者: leo_gongzj 时间: 2013-09-05 12:21 回复 2# yqhenry
问题已经解决了,直接换了一个高版本的。可能是我用的mysql版本太低的缘故。
作者: chinafenghao 时间: 2013-09-09 10:45 @leo_gongzj
good