...
The setup consists of three PostgreSQL database servers:
| primary | The currently active database |
| standby | Changes on the primary node will be replicated to this node |
| witness | The witness is not participating in the replication, but is used to prevent a split-brain situation |
The repmgr daemon proces (repmgrd) monitors the primary node. When it is no longer reachable it will perform a fail-over, and promote the standby node to act as the primary.
...
- Install the PostgreSQL software on the server (as root):
dnf install postgresql15-server repmgr-15* - Initialize the PostgreSQL instance (as root):
/usr/pgsql-15/bin/postgresql-15-setup initdb - Enable and start the service (as root):
systemctl enable --now postgresql-15.service - Setup repmgr
- Create the repmgr user and database as a superuser using psql (as user postgres):
create user repmgr with superuser with password 'secret';create database repmgr with owner repmgr; - Edit the repmgr settings /etc/repmgr/15/repmgr.conf (as root):
node_id=3node_name=c-fews27231conninfo='host=c-fews27231 user=repmgr dbname=repmgr connect_timeout=2'data_directory='/var/lib/pgsql/15/data/'
Register the primary witness node (as user postgres):/usr/pgsql-15/bin/repmgr -f /etc/repmgr/15/repmgr.conf witness register -h c-fews19691 -F - Enable and start the service (as root):
systemctl enable --now repmgr-15.service
- Create the repmgr user and database as a superuser using psql (as user postgres):
...