Skip to content

Disable automatic failover

In order to disable automatic failover, run the following command as user postgres:

shell
/usr/pgsql-14/bin/repmgr service pause

Common setup for all nodes

Install postgres and repmgr version 17 and enable them:

shell
dnf install -y postgresql17-server repmgr_17
systemctl enable postgresql-17
systemctl enable repmgr-17

Create repmgr.conf from the old one:

shell
cp -f /etc/repmgr/14/repmgr.conf /etc/repmgr/17/repmgr.conf 
sed -i s#/var/lib/pgsql/14/data/#/var/lib/pgsql/17/data/# /etc/repmgr/17/repmgr.conf 
sed -i s#/usr/pgsql-14/bin/#/usr/pgsql-17/bin/# /etc/repmgr/17/repmgr.conf 
sed -i s#/etc/repmgr/14/repmgr.conf#/etc/repmgr/17/repmgr.conf# /etc/repmgr/17/repmgr.conf 
sed -i s#/run/repmgr/repmgrd-14.pid#/run/repmgr/repmgrd-17.pid# /etc/repmgr/17/repmgr.conf 
sed -i s#postgresql-14#postgresql-17# /etc/repmgr/17/repmgr.conf

First step: master EM

Set up directories for the new postgres installation:

shell
/usr/pgsql-17/bin/postgresql-17-setup initdb

Stop old version of postgres:

shell
systemctl stop postgresql-14
systemctl disable postgresql-14

Upgrade postgres database (run as postgres user):

shell
/usr/pgsql-17/bin/pg_upgrade --old-bindir=/usr/pgsql-14/bin/ --new-bindir=/usr/pgsql-17/bin/ --old-datadir=/var/lib/pgsql/14/data/ --new-datadir=/var/lib/pgsql/17/data/

Copy postgres configuration files to new location:

shell
cp /var/lib/pgsql/14/data/pg_hba.conf /var/lib/pgsql/17/data/pg_hba.conf
cp /var/lib/pgsql/14/data/postgresql.conf /var/lib/pgsql/17/data/postgresql.conf

Start new postgres services:

shell
systemctl start postgresql-17
systemctl start repmgr-17

Next steps

Update postgres on remaining nodes starting from standby EM and then CPs/MPs one-by-one.

Stop old version of postgres:

shell
systemctl stop postgresql-14
systemctl disable postgresql-14

Clone the database (run as postgres user):

shell
/usr/pgsql-17/bin/repmgr -h <master address> -U repmgr -d repmgr standby clone

Start new version of postgres:

shell
systemctl start postgresql-17

Register standby server (run as postgres user):

shell
/usr/pgsql-17/bin/repmgr -h <master address> -U repmgr -d repmgr standby register --force

Enable automatic failover

Re-enable automatic failover if needed:

shell
/usr/pgsql-17/bin/repmgr service unpause

Remove old postgres

After validating the new postgres installation, you can remove the old postgres binaries and data directory:

shell
yum remove postgresql14-libs postgresql14 postgresql14-server repmgr_14
rm -rf /var/lib/pgsql/14/data