一、问题描述

Mysql主从复制模式中,slave上报错 “relay log read failure”,导致主从同步停止。

mysql> show slave status\G

*************************** 1. row ***************************

Slave_IO_State:

Master_Host: 10.0.0.93

Master_User: slaveuser

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: dd-bin.002542

Read_Master_Log_Pos: 752973519

Relay_Log_File: dd-relay.002949

Relay_Log_Pos: 950583160

Relay_Master_Log_File: dd-bin.002540

Slave_IO_Running: Yes

Slave_SQL_Running: No

Replicate_Do_DB:

Replicate_Ignore_DB: mysql,test,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: 950583017

Relay_Log_Space: 2900478067

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.

Replicate_Ignore_Server_Ids:

Master_Server_Id: 93

1 row in set (0.00 sec)

=============================================

二、原因分析

报错信息为从库“无法读取relay log 里的条目”,可能原因为master库的binglog错误,或slave库的中继日志错误。或者为网络问题及bug原因。

一般是由于网络故障或slave库压力过大,导致relay-log格式错误造成的。找到当前已经同步的时间点,重新设置主从同步,就会产生新的中继日志,恢复正常。

三、问题处理

从"show  slave  status\G"的输出中,找到如下信息:

Relay_Master_Log_File: dd-bin.002540     //slave库已读取的master的binlog

Exec_Master_Log_Pos: 950583017           //在slave上已经执行的position位置点

停掉slave,以slave已经读取的binlog文件,和已经执行的position为起点,重新设置同步。会产生新的中继日志,问题解决。

(不需要指定host,user,password等,默认使用当前已经设置好的)

mysql>stop slave;

mysql>change master to master_log_file='dd-bin.002540' , master_log_pos=950583017;

mysql>start slave;

四、验证结果

再次查看,错误已经解决,slave 开始追 master 的日志

mysql>show  slave status\G

Exec_Master_Log_Pos: 225927489        //slave上已经执行的position已经变化

Seconds_Behind_Master: 58527            //slave  落后主库的时间,单位秒

过几秒钟,再次查看。离与master同步更近了

mysql>show  slave status\G

Exec_Master_Log_Pos: 307469867

Seconds_Behind_Master: 29570

五、从relay-log中验证最后同步日志position。(作为验证,非必须)

还可以从  Relay_Log_File: dd-relay.002949  的记录找到当前已经同步的position。

使用mysqlbinlog 查看中继日志 dd-relay.002949 最后的记录

#mysqlbinlog  dd-relay.002949 >/tmp/relay_log.sql

#tail   /tmp/relay_log.sql

# at 950582947

#140914 3:32:30 server id 93 end_log_pos 950582990 Query thread_id=1256813 exec_time=0 error_code=0

SET TIMESTAMP=1410636750/*!*/;

insert into blog_month_post_count (id, `count`) values (34509691, 0) on duplicate key update `count`=values(`count`)

/*!*/;

# at 950583133

#140914 3:32:30 server id 93 end_log_pos 950583017 Xid = 14033635514

COMMIT/*!*/;

# at 950583160

#140914 3:32:30 server id 93 end_log_pos 950583092 Query thread_id=1256815 exec_time=0 error_code=0

SET TIMESTAMP=1410636750/*!*/;

BEGIN

/*!*/;

DELIMITER ;

# End of log file

ROLLBACK /* added by mysqlbinlog */;

/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

可以看到,中继日志中最后一次执行成功的position 为 950583017,与 Exec_Master_Log_Pos: 950583017 记录一致。

转自

解决Mysql复制Relay log read failure 的问题-雨中行走-51CTO博客 http://blog.51cto.com/wuwei5460/1552798

MySQL主从复制报错1594处理【转】的更多相关文章

  1. mysql主从复制报错解决方案

    mysql主从复制报错解决方案 我先制造个错误 在slave删除个info3字段 然后在master 在info3插入数据 报错如下<pre> Last_SQL_Errno: 1054 L ...

  2. 配置MySQL主从复制报错Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work

    配置MySQL主从复制报错 ``` Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave ha ...

  3. MySQL主从报错1594

    一.主从报错 Relay log read failure 问题原因,MySQL主从使用的是kvm虚拟机,物理机超分严重,在负载高的情况下会kill掉占用资源最多的虚拟机,再启动后导致主从失败 mys ...

  4. mysql主从复制报错 :Incorrect usage of DB GRANT and GLOBAL PRIVILEGES

    在配置mysql主从复制时,想通过 grant replication slave on bbs.* to 'bbs'@'192.168.1.3' identified by '123456'; 来限 ...

  5. MySQL主从复制报错一致性问题解决

    当MySQL主从复制中因为不一致报错的情况,我们第一时间想到的就是使用pt-table-checksum来进行检查主从一致并进行修复,但是使用此工具的前提是主从复制线程都为on状态, 所以这种情况下可 ...

  6. MySQL主从复制报错及解决方法

    mysql> show slave status \G *************************** 1. row *************************** Slave_ ...

  7. mysql主从复制报错(一主一从):从库报错Last_SQL_Errno: 1008

    配置完主从复制后(一主一从),在从库删了一个测试库,结果在从库上使用show slave status\G查看主从同步状态报如下错误:Last_Errno: 1008,经过排查得知:主从环境删除要先在 ...

  8. MySQL主从复制 报错处理

    基于GTID的主从复制: 跳过一个事务: SET @@session.gtid_next = '冲突的GTID号';BEGIN;COMMIT; SET gtid_next = 'AUTOMATIC';

  9. python 3.5.2安装mysql驱动报错

    python 3.5.2安装mysql驱动报错 python 3.5.2安装mysql驱动时出现如下异常: [root@localhost www]# pip install mysql-connec ...

随机推荐

  1. jms和activemq

    一.什么是JMS JMS是java message service的缩写即java消息服务,是java定义的消息中间件(MOM)的技术规范(类似玉JDBC).用于程序之间的异步通信,如果两个应用程序需 ...

  2. java bio总结

    .同步异步.阻塞非阻塞(目前不是很清楚,这篇博客写完后,后续进行处理) 1.同步和异步:关注的是消息的通讯机制, 同步:发起调用后,如果没有得到结果,该调用是不会返回的:该调用者会主动等待调用返回. ...

  3. maven构建myeclipse 工程

    前提:安装maven完成后 mvn -version查看版本 一,新建WEB 工程  mvn archetype:generate -DgroupId={project-packaging} -Dar ...

  4. cmd命令对java程序进行编译时出现:编码GBK的不可映射字符

    原因:由于JDK是国际版的,在编译的时候,如果我们没有用-encoding参数指定JAVA源程序的编码格式,则java.exe首先获得我们才做系统默认采用的编码格式,也即在编译JAVA程序时,若我们不 ...

  5. python 存储引擎 mysql(库,表, 行) 单表多表操作 (foreign key) sql_mode pymysql模块讲解

    ##################总结############### mysql 常用数据类型 整型:tinyint  int(42亿条左右)  bigint 小数:float double dec ...

  6. 混合app开发--js和webview之间的交互总结

    使用场景:原生APP内嵌套H5页面,app使用的是webview框架进行嵌套 这样就存在两种情况 1.原生app调用H5的方法 2.H5调用app的方法 分别讲解下,其实app与H5之间的交互式非常简 ...

  7. vue watch bug记录

    watch中,写箭头函数,获取不到正确的this 换成function,正确取到this

  8. windows安装mysql示例

    1. 下载mysql安装包,如: mysql-5.6.34-winx64.zip2. 解压安装包到指定目录,如:D盘,即:D:\mysql-5.6.34-winx643. 配置 cd D:\mysql ...

  9. mvn打包时添加日期参数

    maven打包时想添加日期参数,如:将"xxx.jar"打包为"xxx-yyyyMMdd.jar"这样的格式.如何实现? 自Maven 2.1.0-M1版本之后 ...

  10. ArcGIS坐标系转换出错:Error 999999执行函数出错 invalid extent for output coordinate system

    本文主要介绍在用ArcGIS做坐标系转换过程中可能会遇到的一个问题,并分析其原因和解决方案. 如下图,对一份数据做坐标系转换: 过了一会儿,转换失败了.错误消息如下: “消息”中提示,“执行函数出错 ...