KingbaseES V8R6集群运维案例之---主库归档失败导致 switchover故障

案例说明:
KingbaseES V8R6集群,备库在执行‘repmgr standby switchover’时,切换失败,出现以下故障:

经检查发现是主库归档配置错误,主库出现归档失败导致。

适用版本:
KingbaseES V8R6

一、问题现象
如下所示,在备库执行:repmgr standby switchover,主备切换失败:

[kingbase@node201 bin]$ ./repmgr standby switchover -h 192.168.1.202 -U esrep -d esrep
[WARNING] following problems with command line parameters detected:
  database connection parameters not required when executing STANDBY SWITCHOVER
.......
[INFO] The output from primary check cmd "repmgr node check --terse -LERROR --archive-ready --optformat" is: "--status=CRITICAL --files=192 --threshold=128
"
[ERROR] number of pending archive files on demotion candidate "node2" is critical
[DETAIL] 192 pending archive files (critical threshold: 128)
[HINT] Kingbase will not shut down until all files are archived; use -F/--force to continue anyway

二、问题分析

在执行‘repmgr standby switchover’进行主备切换时,需要对primary环境进行检测,如果主库环境(比如:主库归档是否成功)不符合切换要求,切换将失败。

集群节点检查工具:repmgr node check

#描述
从复制角度对节点进行一些运行状况检查。
#选项
--csv
输出CSV格式(不使用于单个检查)。
--nagiosNagios格式输出(只使用与单个检查)。
检查的参数
--archive-ready
检查尚未归档的WAL文件数量。
--downstream
检查预期的下游节点是否都已连接。
--replication-lag
检查节点是否滞后(备节点有效)。
--role
检查节点是否有预期的角色。
--slots
检查节点是否存在非活跃的物理复制槽。
--missing-slots
检查是否缺少物理复制槽。
--data-directory-config
检查repmgr.conf的配置项是否与实际的数据目录匹配。

1、按照错误提示信息,在主库执行语句检测primary环境
如下所示,status=CRITICAL,状态异常:

[kingbase@node202 bin]$ ./repmgr node check --terse -LERROR --archive-ready --optformat
--status=CRITICAL --files=192 --threshold=128

如上图所示,在检测主库是否有归档失败的(状态为:*.ready)wal日志数量时,检查发现主库有27个归档失败的wal日志文件。
如下图所示:主库归档正常的检测结果(status=OK)

2、检查sys_wal/archive_status目录下是否有.ready状态的文件(归档失败)

1)检查未归档wal日志
如下所示,文件名为.ready是未归档日志,.done为已归档日志:

[kingbase@node202 sys_log]$ cd ../sys_wal/archive_status
[kingbase@node202 archive_status]$ ls -lh *.ready|wc -l
192

2)检查主库sys_log日志
如下所示,主库节点数据库归档失败:

2024-07-26 17:57:50.150 CST,,,25253,,66a36bd4.62a5,127,,2024-07-26 17:26:44 CST,,0,LOG,00000,"archive command failed with exit code 55","The failed archive command was: export TZ=Asia/Shanghai;/home/kingbase/cluster/R6C8/HAC8/kingbase/bin/sys_rman --config /home/kingbase/kbbr_repo/sys_rman.conf --stanza=kingbase archive-push sys_wal/0000003B00000002000000D7",,,,,,,,""
2024-07-26 17:57:50.150 CST,,,25253,,66a36bd4.62a5,128,,2024-07-26 17:26:44 CST,,0,WARNING,01000,"archiving write-ahead log file ""0000003B00000002000000D7"" failed too many times, will try again later",,,,,,,,,""

如上所示,主库端执行归档失败,存在大量的未归档日志,在执行switchover前的主库环境检测时失败,导致无法执行swithover的切换。

三、问题解决

1、检查主库归档,发现归档路径及archive_command语句配置错误,正确配置后,主库归档成功。
2、将主库archive_status下的*.ready文件清除,执行主库环境检测命令(status=ok):

     [kingbase@node202 bin]$ ./repmgr node check --terse -LERROR --archive-ready --optformat
      --status=OK --files=2

3、备库执行'repmgr standby switchover',可以正常切换。

四、总结

在执行主备switchover切换时,必须保证主备库节点数据库服务运行状态正常,否则在切换过程将会导致失败。

posted @   天涯客1224  阅读(19)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示