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

ops/2024/10/24 2:59:49/

由于平台虚拟机宿主机迁移,导致一套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/ops/127983.html

相关文章

RNN、LSTM 与 Bi-LSTM

一. RNN 循环神经网络(Recurrent Neural Network, RNN)是深度学习领域一类具有内部自连接的神经网络能够学习复杂的矢量到矢量的映射。 最大特点:前面的序列数据可以用作后面的结果预测中。 一个简单的循环神经网络结构,其结构包…

|动漫爬取|001_djangodjango基于Spark的国漫推荐系统的设计与实现2024_tpd6q1o4

目录 系统展示 开发背景 代码实现 项目案例 获取源码 博主介绍:CodeMentor毕业设计领航者、全网关注者30W群落,InfoQ特邀专栏作家、技术博客领航者、InfoQ新星培育计划导师、Web开发领域杰出贡献者,博客领航之星、开发者头条/腾讯云/AW…

Redis Search系列 - 第四讲 支持中文

目录 一、支持中文二、自定义中文词典2.1 Redis Search设置FRISOINI参数2.2 friso.ini文件相关配置1)自定义friso UTF-8字典2)修改friso.ini配置文件 三、实测中文分词效果 一、支持中文 Redis Stack 从版本 0.99.0 开始支持中文文档的添加和分词。中文…

【Hive】8-Hive性能优化及Hive3新特性

Hive性能优化及Hive3新特性 Hive表设计优化 Hive查询基本原理 Hive的设计思想是通过元数据解析描述将HDFS上的文件映射成表 基本的查询原理是当用户通过HQL语句对Hive中的表进行复杂数据处理和计算时,默认将其转换为分布式计算 MapReduce程序对HDFS中的数据进行…

若依框架中根目录与子模块 `pom.xml` 的区别

前言 在使用 Maven 构建的多模块项目中,比如若依(RuoYi)这样的后台管理系统,我们会遇到两种不同作用的 pom.xml 文件:位于项目根目录下的以及每个子模块下的。这两者之间存在一些关键差异,并且理解这些差异…

MATLAB imnoise函数

**MATLAB imnoise函数用于向图像添加不同类型的噪声,以模拟真实世界中的噪声污染情况**。以下是该函数的具体说明: 1. **基本语法和参数**:imnoise函数的基本使用格式为g imnoise(I, type),其中g是添加噪声之后的图像&#xff0c…

6、面向对象八股文(长期更新_整理收集_排版未优化_day06_20个

1、面向对象八股文(长期更新_整理收集_排版已优化_day01_20个) 2、面向对象八股文(长期更新_整理收集_排版已优化_day02_20个) 3、面向对象八股文(长期更新_整理收集_排版未优化_day03_20个) 4、面向对象八股文&#x…

【ROS2实操五】通信机制补充

简介 本章主要介绍关于通信机制的补充内容,比如:分布式框架搭建、重名问题处理、常用API、通信机制工具等等,这些补充内容的知识点比较零散但是每个知识点都不复杂。 学习内容学习收获1.分布式通信的概念、应用场景以及通信规则。能够独立搭…