簡體   English   中英

在 Debian 上設置 repmgr 見證節點

[英]Setting repmgr witness node on Debian

我正在嘗試使用 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

顯然,啟動 repmgr 守護進程的正確命令是: repmgrd -f /etc/prepmgr.conf

建議將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 命令的用戶應該能夠根據您的配置寫入日志。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM