MGR主从不一致问题排查与修复
运行环境
linux:CentOS release 6.8 (Final)
kernel:2.6.32-642.6.2.el6.x86_64
mysql Server version: 5.7.21-20-log Percona Server (GPL),MGR单主模式
1.故障现象
解析binlog
mysqlbinlog -v --base64-output=DECODE-ROWS mysql-bin.000042 --include-gtids='1bb1b861-f776-11e6-3319-010204058070:113111655'
1bb1b861-f776-11e6-3319-010204058070:113111655 该GTID的binlog内容 ycc01 与ycc03服务器内容一致
ycc01.prod.bj2 mysql_3319 SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111655'/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number
# at
# :: server id end_log_pos Delete_rows: table id flags: STMT_END_F
### DELETE FROM `ycc_cfcenter`.`config_center_client_list`
### WHERE
### @=
### @=
### @='10.1.97.131'
### @=''
### @=
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/; ycc03.prod.bj2 mysql_3319 SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111655'/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number
# at
# :: server id end_log_pos Delete_rows: table id flags: STMT_END_F
### DELETE FROM `ycc_cfcenter`.`config_center_client_list`
### WHERE
### @=
### @=
### @='10.1.97.131'
### @=''
### @=
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/;
mysqlbinlog -v --base64-output=DECODE-ROWS mysql-bin.000042 --include-gtids='1bb1b861-f776-11e6-3319-010204058070:113111656'
1bb1b861-f776-11e6-3319-010204058070:113111656 该GTID的binlog内容 ycc01 与ycc03服务器内容不一致
ycc01.db.prod.bj2 mysql_3319 SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111656'/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number
# at
# :: server id end_log_pos Delete_rows: table id flags: STMT_END_F
### DELETE FROM `ycc_cfcenter`.`config_center_client_list`
### WHERE
### @=
### @=
### @='10.1.94.137'
### @=''
### @=
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/; ycc03.db.prod.bj2 mysql_3319
SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111656'/*!*/;
# at
# :: server id end_log_pos Query thread_id= exec_time= error_code=
SET TIMESTAMP=/*!*/;
BEGIN
/*!*/;
# at
# :: server id end_log_pos Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number
# at
# :: server id end_log_pos Write_rows: table id flags: STMT_END_F
### INSERT INTO `ycc_cfcenter`.`config_center_client_list`
### SET
### @=
### @=
### @='10.1.97.131'
### @=''
### @=
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/;
2.原因排查
官方已经反馈社区版MySQL 5.7.26和MySQL 8.0.16 中会修复,如果是企业版客户可以申请最新的hotfix版本。
在未升级 MySQL 版本前,若再发生此类故障,在修复时需要人工检查,检查切换时binlog中 GTID 信息与新主节点对应 GTID 的信息是否一致。
如果不一致需要人工修复至一致状态,一致才可以将被踢出的原主节点加回集群。
参考文档
3.修复过程
3.1 确定故障点
查看故障节点error.log
2019-04-12T12:41:45.834694+08:00 3561943 [ERROR] Slave SQL for channel 'group_replication_applier': Could not execute Write_rows event on table ycc_cfcenter.config_center_client_list; Duplicate entry '136-10.1.94.137-5566' for key 'uniq_idx_project_id', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log FIRST, end_log_pos 327, Error_code: 10622019-04-12T12:41:45.834713+08:00 3561943 [Warning] Slave: Duplicate entry '136-10.1.94.137-5566' for key 'uniq_idx_project_id' Error_code: 1062 |
查看故障节点当前GTID
SHOW MASTER STATUSFILE POSITION Binlog_Do_DB Binlog_Ignore_DB Executed_Gtid_Set ---------------- --------- ------------ ---------------- --------------------------------------------------mysql-bin.000042 747898223 1bb1b861-f776-11e6-3319-010204058070:1-113111661 |
解析故障节点包含【1bb1b861-f776-11e6-3319-010204058070:1-113111661】 GTID 的binlog
##mysqlbinlog -vvv relay-bin-group_replication_applier.000053 --include-gtids="1bb1b861-f776-11e6-3319-010204058070:113111661"
SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111661'/*!*/;# at 703004277#190412 12:41:45 server id 58070 end_log_pos 81 Query thread_id=4163376 exec_time=0 error_code=0SET TIMESTAMP=1555044105/*!*/;BEGIN/*!*/;# at 703004358#190412 12:41:45 server id 58070 end_log_pos 161 Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number 108# at 703004438#190412 12:41:45 server id 58070 end_log_pos 327 Write_rows: table id 108 flags: STMT_END_FBINLOG ''/*!*/;### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183781 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=206 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.97.133' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183788 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=136 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.94.137' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183795 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=206 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.97.131' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */# at 703004604#190412 12:41:45 server id 58070 end_log_pos 354 Xid = 604665142COMMIT/*!*/; |
解析主节点binlog 确定相同内容binlog event 对应的GTID值
##mysqlbinlog -vvv mysql-bin.000042 --include-gtids="1bb1b861-f776-11e6-3319-010204058070:113111660-113111665'
SET @@SESSION.GTID_NEXT= '1bb1b861-f776-11e6-3319-010204058070:113111662'/*!*/;# at 418536376#190412 12:41:45 server id 58070 end_log_pos 418536457 Query thread_id=4163376 exec_time=0 error_code=0SET TIMESTAMP=1555044105/*!*/;BEGIN/*!*/;# at 418536457#190412 12:41:45 server id 58070 end_log_pos 418536537 Table_map: `ycc_cfcenter`.`config_center_client_list` mapped to number 108# at 418536537#190412 12:41:45 server id 58070 end_log_pos 418536703 Write_rows: table id 108 flags: STMT_END_FBINLOG ''/*!*/;### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183781 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=206 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.97.133' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183788 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=136 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.94.137' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */### INSERT INTO `ycc_cfcenter`.`config_center_client_list`### SET### @1=380183795 /* LONGINT meta=0 nullable=0 is_null=0 */### @2=206 /* LONGINT meta=0 nullable=1 is_null=0 */### @3='10.1.97.131' /* VARSTRING(300) meta=300 nullable=1 is_null=0 */### @4='5566' /* VARSTRING(90) meta=90 nullable=1 is_null=0 */### @5=1555044105821 /* LONGINT meta=0 nullable=1 is_null=0 */# at 418536703#190412 12:41:45 server id 58070 end_log_pos 418536730 Xid = 604665142COMMIT/*!*/; |
3.2 确定故障点结果汇总
1.故障节点提示 Duplicate entry '136-10.1.94.137-5566' for key 'uniq_idx_project_id' 有唯一约束冲突
2.故障节点当前GTID 【1bb1b861-f776-11e6-3319-010204058070:1-113111660】
3.故障节点与主节点GTID相差一个值,相同binlog event 主节点GTID【1bb1b861-f776-11e6-3319-010204058070:113111662】 故障节点【1bb1b861-f776-11e6-3319-010204058070:113111661】
3.3 故障节点修复过程
3.3.1 停止故障节点MGR服务
STOP group_replication;
SET GLOBAL super_read_only=0
3.3.2 删除冲突键数据
DELETE FROM config_center_client_list WHERE project_id=136 AND client_ip='10.1.94.137' AND PORT=5566
3.3.3 清除故障节点GTID信息
RESET MASTER
3.3.4 重置故障节点GTID信息,故障节点因唯一约束冲突未重做的binlog event,在主节点对应的GTID为【1bb1b861-f776-11e6-3319-010204058070:113111662】。
SET @@GLOBAL.GTID_PURGED='1bb1b861-f776-11e6-3319-010204058070:1-113111661';
START group_replication;
SHOW MASTER STATUS
3.3.5 在故障节点执行, 需要跳过的GTID只有一个,也可以用以下方法,这样就不需要reset masert。
STOP group_replication;
SET GLOBAL super_read_only=0
set sql_log_bin=0
DELETE FROM config_center_client_list WHERE project_id=136 AND client_ip='10.1.94.137' AND PORT=5566
set sql_log_bin=1
set session gtid_next="1bb1b861-f776-11e6-3319-010204058070:113111661";
begin;commit;
set session gtid_next="AUTOMATIC";
START group_replication;
MGR主从不一致问题排查与修复的更多相关文章
- pt-table-sync修复mysql主从不一致的数据
pt-table-sync简介 顾名思义,它用来修复多个实例之间数据的不一致.它可以让主从的数据修复到最终一致,也可以使通过应用双写或多写的多个不相关的数据库实例修复到一致.同时它还内部集成了pt-t ...
- pt-table-sync 配合pt-table-checksum 修复主从不一致
pt-table-sync 配合pt-table-checksum 修复主从不一致. 先执行下面这条语句,打印出要执行的命令,确认无误后再将 --print 改为 --execute 执行.注意 ...
- MySQL主从不一致修复
场景: 线上正在服务的库由于紧急主从切换导致主从不一致,报错信息如下: Last_Error: Coordinator stopped because there were error(s) in t ...
- Linux 系统故障排查和修复技巧
Linux 系统故障排查和修复技巧 我发现Linux系统在启动过程中会出现一些故障,导致系统无法正常启动,我在这里写了几个应用单用户模式.GRUB命令操作.Linux救援模式的故障修复案例帮助大家了解 ...
- MySQL主从不一致的几种故障总结分析、解决和预防
(1).主从不一致故障,从库宕机,从库启动后重复写入数据报错解决与预防:relay_log_info_repository=TABLE(InnoDB)参数解释说明:若relay_log_info_re ...
- redis 数据库主从不一致问题解决方案
在聊数据库与缓存一致性问题之前,先聊聊数据库主库与从库的一致性问题. 问:常见的数据库集群架构如何? 答:一主多从,主从同步,读写分离. 如上图: (1)一个主库提供写服务 (2)多个从库提供读服务 ...
- Linux启动故障排查和修复技巧
一个执着于技术的公众号 我发现Linux系统在启动过程中会出现一些故障,导致系统无法正常启动,我在这里写了几个应对单用户模式.GRUB命令操作.Linux救援模式的故障修复案例帮助大家了解此类问题的解 ...
- mysql主从不一致解决方法
方法一:忽略错误后,继续同步 该方法适用于主从库数据相差不大,或者要求数据可以不完全统一的情况,数据要求不严格的情况 stop slave; #表示跳过一步错误,后面的数字可变 set global ...
- Linux系统故障排查和修复技巧
本文转自:http://os.51cto.com/art/201304/388384.htm 我发现Linux系统在启动过程中会出现一些故障,导致系统无法正常启动,我在这里写了几个应用单用户模式.GR ...
随机推荐
- loadrunner11中文版破解文档+录制脚本(图/文)
下面是整理后的loadrunner11破解版的所有文件及操作步骤. LoadRunner11安装 1.Loadrunner11下载链接:https://pan.baidu.com/s/15Svt3kt ...
- python网络编程:socket、服务端、客户端
本文内容: socket介绍 TCP: 服务端 客户端 UDP: 服务端 客户端 首发时间:2018-02-08 01:14 修改: 2018-03-20 :重置了布局,增加了UDP 什么是socke ...
- scrapy系列(一)——Python 爬虫框架 Scrapy1.2 Windows 安装教程
scrapy作为一个成熟的爬虫框架,网上有大量的相关教程供大家选择,尤其是关于其的安装步骤更是丰富的很.在这里我想记录下自己的相关经验,希望能给大家带来点帮助. 在scrapy0.24版之前,安装sc ...
- nginx的ngx_http_realip_module模块和http头X-Forwarded-For、X-Real-IP
ngx_http_realip_module模块 realip模块作用:当本机的nginx处于反向代理的后端时可以获取到用户的真实ip.可以让accesslog记录用户真实IP地址. set_real ...
- 消除TortoiseSVN 检出到(checkout)桌面上显示一堆问号
之前不小心直接将版本库的内容检出到桌面,后才发现桌面上的文件图标都变成了问号,新建文件夹也同样如此. 为了解决这个问题,采用如下方法(任何一个检出文件夹均可这样操作): 1.删除桌面隐藏的.SVN文件 ...
- c#权限验证
在开发过程中,需要对访问者的身份做权限验证(再filter中进行权限过滤). 在每次进入控制器方法之前进行调用:如 [ControllerAuth] [RoutePrefix("Clinic ...
- 洗礼灵魂,修炼python(31)--面向对象编程(1)—面向对象,对象,类的了解
面向对象 1.什么是面向对象 (图片来自网络) 哈哈,当然不是图中的意思. 1).面向对象(Object Oriented,OO)是软件开发方法.利用各大搜索引擎得到的解释都太官方,完全看不懂啥意思对 ...
- Mac上用spotlight搜索输入几个字母后闪退
最近使用电脑时遇到的问题: 使用spotlight进行搜索时,只要输入字母超过一定个数(在我的Mac上是3个),spotlight就闪退了. 谷歌搜索得到大部分解决方案是在系统自带词典的偏好设置里取消 ...
- tidb集群某个节点报错之:node_exporter-9100.service failed
今天启动集群tidb时出现一个错误,是某个tikv节点报错:node_exporter-9100.service failed 一个节点的问题会导致整个集群启动失败.去此节点下的日志文件中查找,发现 ...
- vue学习笔记1-基本知识
1.npm 安装node.js的时候会一起安装npm包管理器,能够解决nodejs代码部署问题,常见使用如下: 允许用户从npm服务器下载别人编写的第三方包到本地应用允许用户从npm服务器下载并安装别 ...