repmgr手动切换主从失败,报错‘DETAIL: local node last receive LSN‘

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对这个参数有个超时或者时间检查之类的机制

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值