MySQL8.0主从同步报ERROR 13121错误解决方法

news/2024/10/24 1:34:10/

由于平台虚拟机宿主机迁移,导致一套MySQL主从库从节点故障,从节点服务终止,在服务启动后,恢复从节点同步服务,发现了如下报错:

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: XXXX
                  Master_User: cdbsync
                  Master_Port: 3366
                Connect_Retry: 60
              Master_Log_File: mysql-bin.007843
          Read_Master_Log_Pos: 78338072
               Relay_Log_File: nxscjdtsjkmysqlzc-mysql-master-2-367f7-0-relay-bin.023264
                Relay_Log_Pos: 78930577
        Relay_Master_Log_File: mysql-bin.007841
             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: 13121
                   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, the server was unable to fetch a keyring key required to open an encrypted relay log file, 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: 78930363
              Relay_Log_Space: 300215564
              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: 13121
               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, the server was unable to fetch a keyring key required to open an encrypted relay log file, 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: 2887743427
                  Master_UUID: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e
             Master_Info_File: mysql.slave_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: 241016 02:50:23
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e:1-9339028
            Executed_Gtid_Set: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e:1-9337179
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 1
            Network_Namespace: 
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql>

查看报错信息,提示由于日志损坏、网络问题或bug导致无法获取中继日志中的事件信息。
在尝试了跳过从节点错误方法后,依旧不能正常同步,报错还是一样。
于是,就计划reset slave,重新从中断的日志及position开始复制,整个操作流程如下:

确认Relay_Master_Log_File和Exec_Master_Log_Pos信息:
Relay_Master_Log_File: mysql-bin.007841
Exec_Master_Log_Pos: 78930363

STOP SLAVE;
RESET SLAVE;
CHANGE MASTER TO master_log_file='mysql-bin.007841', master_log_pos=78930363;
START SLAVE;

操作过程:
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> RESET SLAVE;
Query OK, 0 rows affected (0.10 sec)

mysql> CHANGE MASTER TO master_log_file='mysql-bin.007841', master_log_pos=78930363;
ERROR 1776 (HY000): Parameters MASTER_LOG_FILE, MASTER_LOG_POS, RELAY_LOG_FILE and RELAY_LOG_POS cannot be set when MASTER_AUTO_POSITION is active.

根据提示信息,在从节点上设置master_auto_position为0:
mysql> change master to master_auto_position=0;
Query OK, 0 rows affected (0.08 sec)

mysql> CHANGE MASTER TO master_log_file='mysql-bin.007841', master_log_pos=78930363;
Query OK, 0 rows affected (0.06 sec)

重新启动slave:
mysql
mysql> start slave;
Query OK, 0 rows affected (0.01 sec)


mysql> stop slave;
Query OK, 0 rows affected (0.03 sec)

同步正常后,将master_auto_position修改为1并重新启动同步:

mysql> change master to master_auto_position=
    -> 1;
Query OK, 0 rows affected (0.05 sec)

mysql> start slave;
Query OK, 0 rows affected (0.02 sec)

mysql> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: XXXX
                  Master_User: cdbsync
                  Master_Port: 3366
                Connect_Retry: 60
              Master_Log_File: mysql-bin.007843
          Read_Master_Log_Pos: 79142894
               Relay_Log_File: nxscjdtsjkmysqlzc-mysql-master-2-367f7-0-relay-bin.000002
                Relay_Log_Pos: 10529
        Relay_Master_Log_File: mysql-bin.007843
             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: 79142894
              Relay_Log_Space: 10772
              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: 0
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: 2887743427
                  Master_UUID: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e:9339373-9339378
            Executed_Gtid_Set: e4a6bc6b-9de0-11eb-b5e2-fa163e5aaa5e:1-9339378
                Auto_Position: 1
         Replicate_Rewrite_DB: 
                 Channel_Name: 
           Master_TLS_Version: 
       Master_public_key_path: 
        Get_master_public_key: 1
            Network_Namespace: 
1 row in set (0.00 sec)

ERROR: 
No query specified

mysql

至此,整个同步报错处理完成。
 


http://www.ppmy.cn/news/1541483.html

相关文章

Android中的SSL/TLS加密及其作用

Android中的SSL/TLS加密及其作用 SSL/TLS(Secure Sockets Layer/Transport Layer Security)加密技术是保护网络通信安全的关键技术之一,广泛应用于各种网络通信场景,包括Android应用开发。在Android中,SSL/TLS加密技术…

【Next.js 项目实战系列】03-查看 Issue

原文链接 CSDN 的排版/样式可能有问题,去我的博客查看原文系列吧,觉得有用的话,给我的库点个star,关注一下吧 上一篇【Next.js 项目实战系列】02-创建 Issue 查看 Issue 展示 Issue​ 本节代码链接 首先使用 prisma 获取所有…

如何选择适合TikTok直播的IP节点

在数字化时代,直播平台如TikTok正在迅速崛起,成为内容创作者与观众之间互动的主要渠道之一。要想在TikTok上成功直播,选择合适的IP节点是一个至关重要的环节。本文将深入探讨如何选择适合TikTok直播的IP节点,帮助你优化直播质量并…

【Qt】控件——Qt多元素控件、常见的多元素控件、多元素控件的使用、List Widget、Table Widget、Tree Widget

文章目录 QtQt多元素控件List WidgetTable WidgetTree Widget Qt Qt多元素控件 List Widget 使用 QListWidget 能够显示一个纵向的列表。 属性说明currentRow当前被选中的是第几行。count一共有多少行。sortingEnabled是否允许排序。isWrapping是否允许换行。itemAlignment元素…

软考(网工)——网络规划设计

文章目录 🕐综合布线1️⃣结构化布线系统2️⃣综合布线六大子系统3️⃣综合布线物理结构图 🕑网络分析与设计1️⃣网络规划设计模型2️⃣网络流量分析3️⃣网络安全技术措施表4️⃣技术评价 🕒网络结构与功能1️⃣局域网结构类型2️⃣三层架构…

sealed class-kotlin中的封闭类

在 Kotlin 中,sealed class(密封类)是一种特殊的类,用于限制继承的类的数量。密封类可以被用来表示一组有限的类型,通常用于状态管理或表达多种可能的错误类型。 密封类用 sealed 关键字定义,这意味着只能…

CentOS7安装RabbitMQ-3.13.7、修改端口号

本文安装版本: Erlang:26.0 官网下载地址 Erlang RabbitMQ:3.13.7 官网下载地址 RabbitMQ RabbitMQ和Erlang对应关系查看:https://www.rabbitmq.com/which-erlang.html 注:安装erlang之前先安装下依赖文件&#xff0…

rabbitmq 工作队列模式

工作队列模式 一、原理流程图 二、基本知识 工作队列模式(Work Queue Model)是一种消息队列模型,生产者将任务分发到队列中,多个消费者从队列中按顺序获取并处理任务。该模式主要用于负载均衡,确保任务能够均匀分配给…