3分钟解决MySQL主从1594错误简介

Part1:写在最前

1594这个错误看起来挺严重的,会提示你binlog文件或者Relay log损坏了,例如binary log is corrupted、relay log is corrupted之类的看起来很吓人是吧,多数是由于掉电引发的,这也说明了机房配备UPS的重要性。本文来自真实生产案例,感谢网友加内特提供,本人加以故障重现校验。一起来看下如何解决吧。

Part2:完整报错信息mysql> show slave statusG

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

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000006

Read_Master_Log_Pos: 2091061

Relay_Log_File: mysql-relay-bin.000002

Relay_Log_Pos: 1675027

Relay_Master_Log_File: mysql-bin.000006

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: 1675875

Relay_Log_Space: 2093990

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: 1250

Master_UUID: 975d0e4f-bb5d-11e6-98a3-000c29c6361d

Master_Info_File: /data/mysql/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: 161205 21:57:01

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

解决办法

Part1:停止从库mysql> stop slave;

Query OK, 0 rows affected (0.00 sec)

mysql> reset slave all;

Query OK, 0 rows affected (0.25 sec)

mysql>  CHANGE MASTER TO MASTER_HOST='192.168.1.250',MASTER_USER='mysync',MASTER_PASSWORD='MANAGER',MASTER_PORT=3306,MASTER_LOG_FILE='mysql-bin.000006',MASTER_LOG_POS=1675875;

Query OK, 0 rows affected, 2 warnings (0.01 sec)

上述的POS号就是Exec_Master_Log_Pos: 1675875

Part2:起库校验

mysql> start slave;

Query OK, 0 rows affected (0.01 sec)mysql> show slave statusG

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

Slave_IO_State: Waiting for master to send event

Master_Host: 192.168.1.250

Master_User: mysync

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: mysql-bin.000006

Read_Master_Log_Pos: 2091061

Relay_Log_File: mysql-relay-bin.000002

Relay_Log_Pos: 354960

Relay_Master_Log_File: mysql-bin.000006

Slave_IO_Running: Yes

Slave_SQL_Running: Yes

Replicate_Do_DB:

Replicate_Ignore_DB:

Replicate_Do_Table:

Replicate_Ignore_Table:

Replicate_Wild_Do_Table:

Replicate_Wild_Ignore_Table:

Last_Errno: 0

Last_Error:

Skip_Counter: 0

Exec_Master_Log_Pos: 2030552

Relay_Log_Space: 415642

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: 796

Master_SSL_Verify_Server_Cert: No

Last_IO_Errno: 0

Last_IO_Error:

Last_SQL_Errno: 0

Last_SQL_Error:

Replicate_Ignore_Server_Ids:

Master_Server_Id: 1250

Master_UUID: 975d0e4f-bb5d-11e6-98a3-000c29c6361d

Master_Info_File: /data/mysql/master.info

SQL_Delay: 0

SQL_Remaining_Delay: NULL

Slave_SQL_Running_State: Reading event from the relay log

Master_Retry_Count: 86400

Master_Bind:

Last_IO_Error_Timestamp:

Last_SQL_Error_Timestamp:

Master_SSL_Crl:

Master_SSL_Crlpath:

Retrieved_Gtid_Set:

Executed_Gtid_Set:

Auto_Position: 0

1 row in set (0.00 sec)

可以看到从库已经开始在追主库了。

Part3:checksum校验mysql> checksum table helei;

+-------------+------------+

| Table       | Checksum   |

+-------------+------------+

| helei.helei | 2698376487 |

+-------------+------------+

1 row in set (0.00 sec)

mysql> checksum table helei;

+-------------+-----------+

| Table       | Checksum  |

+-------------+-----------+

| helei.helei | 416306435 |

+-------------+-----------+

1 row in set (0.00 sec)

可以看到这里两表已经不一致了,虽然从库完成了同步。但需要重进对主从进行校验了。

主从校验的方法不是本文重点,需要的可移步

http://suifu.blog.51cto.com/9167728/1836551

[root@HE1 ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 9

Server version: 5.6.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> select @@hostname;

+------------+

| @@hostname |

+------------+

| HE1        |

+------------+

1 row in set (0.00 sec)

mysql> select count(*) from helei.helei;

+----------+

| count(*) |

+----------+

|     4738 |

+----------+

1 row in set (0.00 sec)

mysql>

[root@HE3 ~]# mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 12

Server version: 5.6.25-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> select @@hostname;

+------------+

| @@hostname |

+------------+

| HE3        |

+------------+

1 row in set (0.00 sec)

mysql> select count(*) from helei.helei;

+----------+

| count(*) |

+----------+

|     5000 |

+----------+

1 row in set (0.00 sec)

mysql>

这里能看到两表的行数也已经不一致了。

——总结——

MySQL1594通常由于掉电引起,虽然报错内容看起来挺吓人的,但只要手稳心不慌,可以很快解决。由于笔者的水平有限,编写时间也很仓促,文中难免会出现一些错误或者不准确的地方,不妥之处恳请读者批评指正。

mysql主从1594错误_3分钟解决MySQL主从1594错误相关推荐

  1. mysql 1032错误_3分钟解决MySQL 1032 主从错误

    wKioL1gapS3yFcPpAAA4eVx2Dz8496.jpg 3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了,生产库更新后 ...

  2. mysql安全补丁如何处理_3分钟学会mysql数据库的逻辑架构原理

    这篇文章主要是从mysql数据库的逻辑架构来认识掌握mysql的原理.只要是稍微有一点计算机的相关知识相信都能看明白. 一.笼统的逻辑架构 先给出一张逻辑架构图,这张图是让你从宏观的角度来分析认识一下 ...

  3. 3分钟解决MySQL 1032 主从错误(转)

    转自  https://blog.51cto.com/suifu/1845457 3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了, ...

  4. 3分钟解决MySQL 1032 主从错误

    3分钟解决MySQL 1032主从错误 Part1:写在最前 1032错误----现在生产库中好多数据,在从库误删了,生产库更新后找不到了,现在主从不同步了,再跳过错误也没用,因为没这条,再更新还会报 ...

  5. mysql主从切换gtid不一致_解决mysql使用GTID主从复制错误问题

    解决mysql使用GTID主从复制错误问题 做MySQL主从的话肯定会遇到很多同步上的问题, 大多数都是由于机器宕机,重启,或者是主键冲突等引起的从服务器停止工作, 这里专门收集类似问题并提供整理解决 ...

  6. mysql数据没有同步更新_解决MySQL的主从数据库没有同步的两种方法

    问题 今天发现Mysql的主从数据库没有同步 先上Master库: mysql>show processlist; 查看下进程是否Sleep太多.发现很正常. show master statu ...

  7. mysql更改加密方式后密码错误_关于解决mysql 8.0及以上 修改加密方式以及密码

    如果密码已经忘记 或者修改过加密方式后出现密码错误 不用卸载mysql 直接将解压后的mysql文件都删除 ,并将压缩包重新解压再此文件夹中 然后重新安装mysql Windows 上安装 MySQL ...

  8. mysql不是内部批处理文件怎么解决,mysql不是内部或外部命令也不是可运行的程序或批处理文件...

    MySQL集群 MySQL集群 1.MySQL为什么需要集群? 问题:100W的客户端,每3分钟上传一次订单数据,数据库怎么设计? MySQL和MongoDB插入数据比较: MySQL:600/s事务 ...

  9. mysql 5.6 登录 警告_解决mysql登录出现警告问题的简单方法

    解决mysql登录出现警告问题的简单方法 发布时间:2020-05-11 11:50:39 来源:亿速云 阅读:125 作者:三月 本文主要给大家介绍解决mysql登录出现警告问题的简单方法,文章内容 ...

最新文章

  1. react native native module
  2. 哈工大 c语言测试与系统控制 ad,哈工大——c语言在测量与控制中应用实验报告.pdf...
  3. 如何在endnote列表中显示research note
  4. java 微信证书文件_JAVA微信企业付款如何使用证书、证书调用实例
  5. java中的内存泄漏
  6. Java就业前景怎么样?值得学吗?
  7. oracle10g检测未通过,win64bit安装oracle 10g版本检查未通过解决 提示要求的结果: 5.0,5.1,5.2,6.0 之一 实际结果: 6.1...
  8. Ubuntu被曝严重漏洞:切换系统语言+输入几行命令,就能获取root权限(仅支持ubuntu桌面版、提权)
  9. android 框架_推荐一个更贴近 android 场景的启动框架 | Anchors
  10. 5元的小乌龟吃什么_五月最适合吃这菜,5元一斤,两三天吃一次,鲜嫩正当时好美味...
  11. 【数据分析】目标优化矩阵表确定权重
  12. Java和python哪个好,学哪个有用。
  13. vue3.0中使用echarts
  14. 贴片电容COG、NPO、X7R、Y5V、X5R介质的区别
  15. word怎么让页码在指定页面从1开始
  16. Win10 Ubuntu16.04 时间同步问题
  17. Mac安装Jadx反编译工具
  18. face_recognition模块方法集合
  19. 标签云TagCloud
  20. dim=0与dim=1_CodingPark编程公园

热门文章

  1. option标签selected=selected属性失效的问题
  2. 前端学习---css基本知识
  3. http1.X与2.0
  4. CSS Grid网格布局全攻略
  5. express接受get数据
  6. 在商城系统开发时遇到商品的多级分类,为增强扩展性,子类可以任意添加,此类问题数据库如何设计...
  7. class threading.Thread()说明:
  8. ExtJs实践(3)——xtype名称与控件对应
  9. openssl不是内部或外部命令_OpenSSL新架构蓝图
  10. python填表_小Python填表得到d