diff --git a/Dockerfile b/Dockerfile index 85fe43c..e98880d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,5 +8,6 @@ RUN apt-get update && \ COPY --chmod=666 repmgr.conf /etc/repmgr.conf COPY --chmod=644 --chown=postgres profile /var/lib/postgresql/.profile +COPY --chmod=755 postgres.sh /usr/local/bin/postgres COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/ diff --git a/docker-entrypoint-initdb.d/00-main.sh b/docker-entrypoint-initdb.d/00-main.sh index 4e540cb..8b3b68b 100755 --- a/docker-entrypoint-initdb.d/00-main.sh +++ b/docker-entrypoint-initdb.d/00-main.sh @@ -69,6 +69,7 @@ case "$REPMGR_NODE_ROLE" in echo "hot_standby = on" >> /var/lib/postgresql/data/postgresql.conf echo "max_wal_senders = 10" >> /var/lib/postgresql/data/postgresql.conf echo "max_replication_slots = 10" >> /var/lib/postgresql/data/postgresql.conf + echo "shared_preload_libraries = 'repmgr'" >> /var/lib/postgresql/data/postgresql.conf if [[ -n $POSTGRES_MAX_CONNECTIONS ]]; then echo "max_connections = ${POSTGRES_MAX_CONNECTIONS}" >> /var/lib/postgresql/data/postgresql.conf fi diff --git a/postgres.sh b/postgres.sh new file mode 100644 index 0000000..6348e3b --- /dev/null +++ b/postgres.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +repmgrd -f /etc/repmgr.conf --pid-file /tmp/repmgrd.pid & + +export PATH="/usr/lib/postgresql/15/bin:${PATH}" + +exec "$@" diff --git a/repmgr.conf b/repmgr.conf index be765b7..9edfd66 100644 --- a/repmgr.conf +++ b/repmgr.conf @@ -1,3 +1,8 @@ data_directory = '/var/lib/postgresql/data' use_replication_slots = on pg_bindir = '/usr/lib/postgresql/15/bin/' +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' +primary_visibility_consensus = on +