Executed_Gtid_Set有多个值

搭建MySQL主从时发现个问题,问题描述:
主库:192.168.161.131
从库:192.168.161.132
在从库执行show slave status\G结果如下:

root@localhost:(none) 10:31:26> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.161.131
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 862
Relay_Log_File: k8sworker-relay-bin.000002
Relay_Log_Pos: 1075
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
···
Retrieved_Gtid_Set: 97333d77-dc8e-11ee-b769-0050562db0fc:1-3
Executed_Gtid_Set: 97333d77-dc8e-11ee-b769-0050562db0fc:1-3,
9a677ee9-dc8e-11ee-9d6e-0050562b8bce:1-2
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)

复制状态是双Yes,但是可以看到Executed_Gtid_Set的值有两个: 9733*** 和 9a677***

多个GTID值产生的原因,可能是该测试库曾经是其他库的从库,后面主从复制关系被改变过,但是没有对GTID的值进行清理。多个GTID值看着很不清晰,也可能会影响双主模式的搭建。
在从库上操作:

第一步、stop slave;
并记录对应的Executed_Gtid_Set值:97333d77-dc8e-11ee-b769-0050562db0fc:1-3
第二步、show master statusG
查看对应Executed_Gtid_Set值是否和上面保持一致,一般情况下是一致的。
第三步:reset master;
重置从库上的binlog,该操作会清空从库上的mysql.gtid_executed表中的内容
第四步:set global gtid_purged='97333d77-dc8e-11ee-b769-0050562db0fc:1-3';
重置从库的gtid_purged的值
第五步:start slave; 重启复制关系
第六步:show slave statusG 查看最终结果
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 97333d77-dc8e-11ee-b769-0050562db0fc:1-3
Executed_Gtid_Set: 97333d77-dc8e-11ee-b769-0050562db0fc:1-3
Auto_Position:

从库B上通过以上6个步骤的操作,最终的Executed_gtid_set已经变为一个了。它的UUID是主库A的UUID。

posted @   w'dwd  阅读(221)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示