Mysql Last_Errno: 1594 主从实例断电GTID同步修复

mysql5.6 GTID 同步模式

环境说明:centos7,mysql5.6,GTID同步模式

起因

磁盘阵列存储异常,导致虚拟机脱盘,分区挂载只读,主机修复重启后,从库无法同步主库,提示relay log读取到错误。

show slave status\G

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.

 

解决思路:重置同步信息,重新读取主库binlog,重新写入从库。

 

记录从库最后同步信息

1、show slave status\G

Relay_Master_Log_File: mysql-binlog.000249

Exec_Master_Log_Pos: 92240744

Executed_Gtid_Set: 03b8b27c-f9b8-11e8-b9e5-000c29cc1e94:396662759-397477758

 

2、提取信息

主库UUID:03b8b27c-f9b8-11e8-b9e5-000c29cc1e94

主库binlog位置: File =》mysql-binlog.000249 Pos=》 92240744

 

主库可以验证对应文件位置的binlog信息(可忽略,主要验证主库binlog信息是否匹配上面提取的数据)

mysql -uroot -p -e 'show binlog events in "mysql-binlog.000254"' >> 254.log

 

开始恢复

1、从库执行,停止同步

stop slave;

2、关闭自动匹配GTID

change master to master_auto_position=0;

3、重置同步信息

reset slave;

reset master;

change master to master_host='master_ip', master_user='repl', master_password='rep_123456', master_port=3306, master_log_file='mysql-binlog.000249', master_log_pos=92240744;

** 文件位置跟之前记录的要保持一致。

4、启动同步线程

start slave;

 

5、查看状态:

show slave status\G

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

出现双YES,就看到希望了!

 

补充:

如果从库日志刷盘机制为非双1 配置,可能会出现主键冲突情况,如果数据不是特别重要可以使用跳过GTID的方式修复

方法一:设置空事务跳过错误

1、show slave status \G

Executed_Gtid_Set: 03b8b27c-f9b8-11e8-b9e5-000c29cc1e94:396662759-397477758

确定异常GTID事务号:03b8b27c-f9b8-11e8-b9e5-000c29cc1e94:397477759

2、跳过GTID

stop slave;

set gtid_next='03b8b27c-f9b8-11e8-b9e5-000c29cc1e94:397477759'; #(Executed_Gtid_Set + 1)

begin;

commit;

set gtid_next='AUTOMATIC';

start slave;

方法二:重置master方法跳过错误


mysql> STOP SLAVE;
mysql> RESET MASTER;
mysql> SET @@GLOBAL.GTID_PURGED =’03b8b27c-f9b8-11e8-b9e5-000c29cc1e94:396662759-397477759'
mysql> START SLAVE;

3、检验状态

show slave status\G

可重复上面跳过步骤。

如果数据比较重要,建议重做从库。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值