mysql 5.7.34 gtid 复制模式下执行 reset master 命令后 slave 节点的处理

Posted 云居

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql 5.7.34 gtid 复制模式下执行 reset master 命令后 slave 节点的处理相关的知识,希望对你有一定的参考价值。

问题描述

主从同步报如下错误:

Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Slave has more GTIDs than the master has, using the master’s SERVER_UUID. This may indicate that the end of the binary log was truncated or that the last binary log file was lost, e.g., after a power or disk failure when sync_binlog != 1. The master may or may not have rolled back transactions that were already replicated to the slave. Suggest to replicate any transactions that master has rolled back from slave to master, and/or commit empty transactions on master to account for transactions that have been’

系统环境

os: centos 7.4
db: mysql 5.7.34

192.168.56.60 node1 # master
192.168.56.61 node2 # slave

处理过程

[root@node2 ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)
[root@node2 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \\g.
Your MySQL connection id is 19
Server version: 5.7.34 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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 version();
+-----------+
| version() |
+-----------+
| 8.0.19 |
+-----------+
1 row in set (0.00 sec)

reset master
mysql> reset master;
Query OK, 0 rows affected (0.38 sec)

mysql> show master status;
+---------------+----------+--------------+--------------------------------------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+---------------+----------+--------------+--------------------------------------------------+-------------------+
| binlog.000001 | 155 | | information_schema,mysql,performation_schema,sys | |
+---------------+----------+--------------+--------------------------------------------------+-------------------+
1 row in set (0.00 sec)

mysql>

mysql> show slave status\\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.56.60
Master_User: replicator
Master_Port: 3306
Connect_Retry: 10
Master_Log_File:
Read_Master_Log_Pos: 4
Relay_Log_File: node2-relay-bin.000002
Relay_Log_Pos: 4
Relay_Master_Log_File:
Slave_IO_Running: No
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: information_schema,mysql,performance_schema,sys
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: 0
Relay_Log_Space: 155
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: Yes
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: 13114
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: \'Slave has more GTIDs than the master has, using the master\'s SERVER_UUID. This may indicate that the end of the binary log was truncated or that the last binary log file was lost, e.g., after a power or disk failure when sync_binlog != 1. The master may or may not have rolled back transactions that were already replicated to the slave. Suggest to replicate any transactions that master has rolled back from slave to master, and/or commit empty transactions on master to account for transactions that have been\'
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 5660
Master_UUID: f35f7fd2-5828-11ea-a590-08002799719d
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: 200316 17:58:15
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set: f35f7fd2-5828-11ea-a590-08002799719d:1
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
Master_public_key_path: /var/lib/mysql/public_key.pem
Get_master_public_key: 1
Network_Namespace:
1 row in set (0.00 sec)

Slave_IO_Running: No
Slave_SQL_Running: Yes
Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: ‘Slave has more GTIDs than the master has, using the master’s SERVER_UUID. This may indicate that the end of the binary log was truncated or that the last binary log file was lost, e.g., after a power or disk failure when sync_binlog != 1. The master may or may not have rolled back transactions that were already replicated to the slave. Suggest to replicate any transactions that master has rolled back from slave to master, and/or commit empty transactions on master to account for transactions that have been’

解决方法

1)在从上执行 reset master;

在从库上执行这个命令的作用是 清空从库的 gtid

reset master;

2)然后继续观察,如果还报错就

stop slave;

reset slave;

重新指定主;

start slave;

————————————————
版权声明:本文为CSDN博主「数据库人生」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ctypyb2002/article/details/104906723/

喜欢请赞赏一下啦^_^

微信赞赏

支付宝赞赏

以上是关于mysql 5.7.34 gtid 复制模式下执行 reset master 命令后 slave 节点的处理的主要内容,如果未能解决你的问题,请参考以下文章

MySQL OCP888题解067-GTID复制模式下的限制

GTID模式复制异常处理

MySQL MHA--故障切换模式(GTID模式和非GTID模式)

与MySQL传统复制相比,GTID有哪些独特的复制姿势

关于GTID模式下备份时 --set-gtid-purged=OFF 参数的实验

MySQL 什么是GTID?