0

我正在尝试使用 PostgtrSql 11 在 Debian 上设置 repmgr 版本 5。
似乎文档更面向 centos/RHEL。

当我尝试设置 witnes 节点以启动 repmgr 守护程序时,我收到一个错误,不知道在哪里寻找错误的原因。

这是我的 repmgr.conf 文件:

node_id=3
node_name='PG-Node-Witness'
conninfo='host=10.97.7.140 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/var/lib/postgresql/11/main'
failover='automatic'
promote_command='/usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file'
follow_command='/usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n'
priority=60
monitor_interval_secs=2
connection_check_type='ping'
reconnect_attempts=6
reconnect_interval=8
primary_visibility_consensus=true
standby_disconnect_on_failover=true
repmgrd_service_start_command='sudo /etc/init.d/repmgrd start'  #??????
repmgrd_service_stop_command='sudo //etc/init.d/repmgrd stop'#??????
service_start_command='sudo /usr/bin/systemctl start postgresql@11-main.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql@11-main.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql@11-main.service'
service_reload_command='sudo /usr/bin/systemctl relaod postgresql@11-main.service'
monitoring_history=yes
log_status_interval=60

注册没问题:

repmgr -f /etc/repmgr.conf witness register -h 10.97.7.97

INFO: connecting to witness node "PG-Node-Witness" (ID: 3)
INFO: connecting to primary node
NOTICE: attempting to install extension "repmgr"
NOTICE: "repmgr" extension successfully installed
INFO: witness registration complete
NOTICE: witness node "PG-Node-Witness" (ID: 3) successfully registered

repmgr 守护进程也可以空运行:

$repmgr -f /etc/repmgr.conf daemon start --dry-run
INFO: prerequisites for starting repmgrd met
DETAIL: following command would be executed:
 sudo /usr/bin/systemctl start postg...@11-main.service

我设置 /etc/default/repmgrd :

REPMGRD_ENABLED=yes

REPMGRD_CONF="/etc/repmgr.conf"

但是在尝试运行守护程序启动时仍然会出错:

$ repmgr -f /etc/repmgr.conf daemon start

我得到:

NOTICE: executing: "sudo  /etc/init.d/repmgrd start"
ERROR: repmgrd does not appear to have started after 15 seconds
HINT: use "repmgr service status" to confirm that repmgrd was successfully started
4

2 回答 2

0

建议repmgrd作为 systemd 服务运行,根据文档(对于 debian),您可能首先需要配置/etc/default/repmgrd,我的配置如下所示:

# default settings for repmgrd. This file is source by /bin/sh from
# /etc/init.d/repmgrd

# disable repmgrd by default so it won't get started upon installation
# valid values: yes/no
REPMGRD_ENABLED=yes

# configuration file (required)
REPMGRD_CONF="/etc/repmgr/12/repmgr.conf"

# additional options
REPMGRD_OPTS="--daemonize=false"

# user to run repmgrd as
REPMGRD_USER=postgres

# repmgrd binary
REPMGRD_BIN=/bin/repmgrd

# pid file
REPMGRD_PIDFILE=/var/run/repmgrd.pid

其次,我会重新访问sudoers(visudo) 以检查non-root用户是否可以执行sudo /etc/init.d/repmgrd start.

此外,运行 repmgr 命令的用户应该能够根据您的配置写入日志。

于 2021-03-02T23:50:40.560 回答
0

显然,启动 repmgr 守护进程的正确命令是: repmgrd -f /etc/prepmgr.conf

于 2020-07-03T15:55:09.723 回答