Configure PostgreSQL Replication and Failover With Repmgr
Configure PostgreSQL Replication and Failover With Repmgr
OS: RHEL 9
Repmgr version: 15
On Primary server:
# Install PostgreSQL:
vim $PGDATA/postgresql.conf
listen_addresses = '*'
wal_level = replica
archive_mode = on
archive_command = '/bin/true'
max_wal_senders = 10
max_replication_slots = 10
wal_keep_size = 1GB
hot_standby = on
shared_preload_libraries = 'repmgr'
save&exit
Step4) Restart and check the PostgreSQL services
#######################################Primary_server#######################
###################################Standby_server###########################
save&exit
#Reload configurations
SELECT pg_reload_conf();
#Check Connectivity
vim /var/lib/pgsql/repmgr.conf
cluster='failovertest'
node_id=1
node_name=node1
data_directory='/var/lib/pgsql/15/data/'
failover=automatic
save&exit
Step8) Register the primary server with repmgr
On Standby server:
# Install PostgreSQL:
Note: The above step of initialization of the cluster is not needed on the standby server.
Step10) Install repmgr
vim /var/lib/pgsql/repmgr.conf
node_id=2
node_name=node2
data_directory='/var/lib/pgsql/15/data'
failover=automatic
save&exit
Step12) Perform the dry run and test if our configuration is correct
On Primary server:
On Standby server: