repmgr:5.4.0
pgsql: 14.2
OS:centos7.8

搭建好的repmgr主从使用命令手动进行切换失败,日志如下

postgres@db02:~$ repmgr standby switchover
NOTICE: executing switchover on node "db02" (ID: 2)
NOTICE: local node "db02" (ID: 2) will be promoted to primary; current primary "db01" (ID: 1) will be demoted to standby
NOTICE: stopping current primary node "db01" (ID: 1)
NOTICE: issuing CHECKPOINT on node "db01" (ID: 1)
DETAIL: executing server command "/usr/lib/postgresql/14/bin/pg_ctl  -D /var/lib/postgresql/14/main -W -m fast stop"
INFO: checking for primary shutdown; 1 of 60 attempts ("shutdown_check_timeout")
INFO: checking for primary shutdown; 2 of 60 attempts ("shutdown_check_timeout")
NOTICE: current primary has been cleanly shut down at location 0/4000016
NOTICE: waiting up to 30 seconds (parameter "wal_receive_check_timeout") for received WAL to flush to disk
INFO: sleeping 1 of maximum 30 seconds waiting for standby to flush received WAL to disk
INFO: sleeping 2 of maximum 30 seconds waiting for standby to flush received WAL to disk
INFO: sleeping 3 of maximum 30 seconds waiting for standby to flush received WAL to disk
[...]
INFO: sleeping 29 of maximum 30 seconds waiting for standby to flush received WAL to disk
INFO: sleeping 30 of maximum 30 seconds waiting for standby to flush received WAL to disk
WARNING: local node "db02" is behind shutdown primary "db01"
DETAIL: local node last receive LSN is 0/3D02000, primary shutdown checkpoint LSN is 0/4000016
NOTICE: aborting switchover
HINT: use --always-promote to force promotion of standby

postgresql.conf中有这样一个内容

archive_mode = on
#因为使用repmgr,所以不需要归档这里设置true禁用归档
archive_command = '/bin/true'

通过查询发现,正是archive_command 这里使用'/bin/true',导致repmgr切换失败
将命令改为

archive_command = '{ sleep 5; true; }'

再次手动执行主从切换成功

具体原因目前没有明确解释估计是repmgr或pg这个参数有个超时或者时间检查之类的机制

原文地址:https://blog.csdn.net/mayifan0/article/details/134783155

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_39638.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注