This commit is contained in:
Bernhard Radermacher
2026-02-24 10:11:10 +01:00
parent 8799f67db6
commit a50eb92c6d

View File

@@ -110,15 +110,14 @@ repmgr_setup_conf() {
printf "node_id = %s\n" "$REPMGR_NODE_ID"
printf "node_name = %s\n" "$REPMGR_NODE_NAME"
printf "conninfo = 'host=%s dbname=repmgr user=repmgr connect_timeout=2'\n" "$REPMGR_NODE_NAME"
printf "location = '%s'\n" "$REPMGR_NODE_LOCATION"
printf "\n"
printf "data_directory = '/var/lib/postgresql/data'\n"
printf "use_replication_slots = on\n"
printf "pg_bindir = '/usr/lib/postgresql/15/bin/'\n"
printf "\n"
printf "failover = automatic\n"
printf "promote_command = '/usr/bin/repmgr standby promote -f /etc/repmgr/repmgr.conf --log-to-file'\n"
printf "follow_command = '/usr/bin/repmgr standby follow -f /etc/repmgr/repmgr.conf --log-to-file --upstream-node-id=%n'\n"
printf "promote_command = '/usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file'\n"
printf "follow_command = '/usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n'\n"
printf "reconnect_attempts = 3\n"
printf "reconnect_interval = 5\n"
} > /etc/repmgr/repmgr.conf
@@ -153,19 +152,19 @@ if [[ ! -s "$PGDATA/PG_VERSION" ]]; then
unset PGPASSWORD
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf primary register
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr.conf primary register
else
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone --dry-run &> /dev/null
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr.conf standby clone --dry-run &> /dev/null
do
echo "Upstream host not ready. Waiting for 5 minutes..."
sleep 300
done
echo "Upstream host found..."
/usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone
/usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr.conf standby clone
docker_temp_server_start
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf standby register --force
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr.conf standby register --force
fi
@@ -177,7 +176,7 @@ set -m
postgres &
sleep 10
repmgrd -f /etc/repmgr/repmgr.conf --pid-file /tmp/repmgrd.pid
repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid
while true
do