etc to vol
This commit is contained in:
@@ -6,8 +6,9 @@ RUN apt-get update && \
|
|||||||
&& \
|
&& \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
COPY --chmod=666 repmgr.conf /etc/repmgr.conf
|
RUN install --verbose --directory --owner postgres --group postgres --mode 1777 /etc/repmgr
|
||||||
|
VOLUME /etc/repmgr
|
||||||
|
|
||||||
COPY --chmod=644 --chown=postgres profile /var/lib/postgresql/.profile
|
COPY --chmod=644 --chown=postgres profile /var/lib/postgresql/.profile
|
||||||
# COPY --chmod=755 postgres.sh /usr/local/bin/postgres
|
# COPY --chmod=755 postgres.sh /usr/local/bin/postgres
|
||||||
COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
|
COPY docker-entrypoint-initdb.d/* /docker-entrypoint-initdb.d/
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,18 @@ create_hba() {
|
|||||||
echo "host all all all scram-sha-256" >> /var/lib/postgresql/data/pg_hba.conf
|
echo "host all all all scram-sha-256" >> /var/lib/postgresql/data/pg_hba.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "node_id = ${REPMGR_NODE_ID}" >> /etc/repmgr.conf
|
echo "node_id = ${REPMGR_NODE_ID}" > /etc/repmgr/repmgr.conf
|
||||||
echo "node_name = ${REPMGR_NODE_NAME}" >> /etc/repmgr.conf
|
echo "node_name = ${REPMGR_NODE_NAME}" >> /etc/repmgr/repmgr.conf
|
||||||
echo "conninfo = 'host=${REPMGR_NODE_NAME} dbname=repmgr user=repmgr connect_timeout=2'" >> /etc/repmgr.conf
|
echo "conninfo = 'host=${REPMGR_NODE_NAME} dbname=repmgr user=repmgr connect_timeout=2'" >> /etc/repmgr/repmgr.conf
|
||||||
echo "location = '${REPMGR_NODE_LOCATION}'" >> /etc/repmgr.conf
|
echo "location = '${REPMGR_NODE_LOCATION}'" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "data_directory = '/var/lib/postgresql/data'" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "use_replication_slots = on" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "pg_bindir = '/usr/lib/postgresql/15/bin/'" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "failover = automatic" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "promote_command = '/usr/bin/repmgr standby promote -f /etc/repmgr.conf --log-to-file'" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "follow_command = '/usr/bin/repmgr standby follow -f /etc/repmgr.conf --log-to-file --upstream-node-id=%n'" >> /etc/repmgr/repmgr.conf
|
||||||
|
echo "primary_visibility_consensus = on" >> /etc/repmgr/repmgr.conf
|
||||||
|
|
||||||
|
|
||||||
if [[ -n $REPMGR_UPSTREAM ]] && [[ -z $REPMGR_NODE_ROLE ]]; then
|
if [[ -n $REPMGR_UPSTREAM ]] && [[ -z $REPMGR_NODE_ROLE ]]; then
|
||||||
REPMGR_NODE_ROLE="standby"
|
REPMGR_NODE_ROLE="standby"
|
||||||
@@ -40,22 +48,22 @@ case "$REPMGR_NODE_ROLE" in
|
|||||||
standby )
|
standby )
|
||||||
docker_temp_server_stop
|
docker_temp_server_stop
|
||||||
rm -rf /var/lib/postgresql/data/*
|
rm -rf /var/lib/postgresql/data/*
|
||||||
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr.conf standby clone --dry-run &> /dev/null
|
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone --dry-run &> /dev/null
|
||||||
do
|
do
|
||||||
echo "Upstream host not ready. Waiting for 5 minutes..."
|
echo "Upstream host not ready. Waiting for 5 minutes..."
|
||||||
sleep 300
|
sleep 300
|
||||||
done
|
done
|
||||||
echo "Upstream host found..."
|
echo "Upstream host found..."
|
||||||
/usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr.conf standby clone
|
/usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -U repmgr -f /etc/repmgr/repmgr.conf standby clone
|
||||||
server_start
|
server_start
|
||||||
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr.conf standby register
|
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf standby register
|
||||||
;;
|
;;
|
||||||
witness )
|
witness )
|
||||||
create_repmgr
|
create_repmgr
|
||||||
docker_temp_server_stop
|
docker_temp_server_stop
|
||||||
create_hba
|
create_hba
|
||||||
server_start
|
server_start
|
||||||
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -f /etc/repmgr.conf witness register &> /dev/null
|
until /usr/lib/postgresql/15/bin/repmgr -h $REPMGR_UPSTREAM -f /etc/repmgr/repmgr.conf witness register &> /dev/null
|
||||||
do
|
do
|
||||||
echo "Primary host not ready. Waiting for 5 minutes..."
|
echo "Primary host not ready. Waiting for 5 minutes..."
|
||||||
sleep 300
|
sleep 300
|
||||||
@@ -75,6 +83,6 @@ case "$REPMGR_NODE_ROLE" in
|
|||||||
fi
|
fi
|
||||||
create_hba
|
create_hba
|
||||||
server_start
|
server_start
|
||||||
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr.conf primary register
|
/usr/lib/postgresql/15/bin/repmgr -f /etc/repmgr/repmgr.conf primary register
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user