PostgreSQL Streaming Replication by Using Repmgr Tool
Primary Database Standby Database
PostgreSQL Version 17v 17v
Data directory /u01/pgserver/cluster01 /u01/pgserver/cluster01
Binary Location /usr/pgsql-17/bin /usr/pgsql-17/bin
Port Number 5432 5432
Tablespace’s /u02/tbs01, /u02/tbs02 /u02/tbs01, /u02/tbs02
WAL archive Directory /u01/pgserver/archives /u01/pgserver/archives
Note: For PostgreSQL streaming replication, the major version of PostgreSQL on both the primary and
standby servers must be identical. However, minor version differences (e.g., 17.1 vs. 17.2) are
generally supported and do not affect replication compatibility.
Streaming Replication is a PostgreSQL method that enables real-time data replication from a primary
server to one or more standby (replica) servers. It continuously sends the Write-Ahead Log (WAL) data
from the primary to the standby servers over a network connection. This ensures that the standby
PD 1
PostgreSQL Streaming Replication by Using Repmgr Tool
servers are nearly up to date with the primary, allowing for high availability, disaster recovery, and load
balancing for read-only queries.
repmgr (Replication Manager) is an open-source tool developed by EnterpriseDB that simplifies and
automates the management of PostgreSQL streaming replication clusters. Helps with Automated
failover, switchover, and monitoring.
Note: Without a replication manager, we can only do a failover(promote), not a switchover in one
command. And We have used the same data directory location on both the primary and standby
systems to avoid conflicts. It is highly recommended to keep the same path.
Step 1. Verify the PostgreSQL primary server data directory, tablespaces and archive mode
PD 2
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 2. Modify replication-related parameters on the Primary server in postgresql.conf file
Step 3. Modify Access control parameter to allow the remote connection for replication in
pg_hba.conf
PD 3
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 4. Once All parameters updated then restart PostgreSQL database server.
Step 5. On standby server Install PostgreSQL repository and 17v software.
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-
redhat-repo-latest.noarch.rpm
dnf install -y postgresql17-server postgresql17-contrib
Step 6. Setup Postgres User password on standby server
Step 7. Create Data directory, tablespaces directory and archive WAL directory on standby
PD 4
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 8. Create environment variable file on standby to execute PostgreSQL utilities.
Step 9. Perform the Passwordless ssh configuration (User equivlance Configuration) between
primary and Standby servers
Step 10. Install replication manager(repmgr) software on both primary and standby server.
PD 5
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 11. On Both primary and standby Configure repmgr parameter in repmgr configuration
file.
By default location - /etc/repmgr/17/repmgr.conf
On Primary Add below lines in /etc/repmgr/17/repmgr.conf – root user
Step 12. Connect primary server and create repmgr database to store repmgr replication
information.
PD 6
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 13. On Standby Add below lines in /etc/repmgr/17/repmgr.conf – root user
Step 14. Register Primary PostgreSQL server as primary in Repmgr - On Primary server
Step 15. Configure or Build standby By Cloning Primary server
PD 7
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 16. Change IP address on Standby server in postgresql.conf file
Step 17. Start standby server and register as standby in repmgr configuration.
Step 18. Verify repmgr status and replication manager
PD 8
PostgreSQL Streaming Replication by Using Repmgr Tool
Step 19. Verify Replication on primary and standby
PD 9
PostgreSQL Streaming Replication by Using Repmgr Tool
Thank You
PD 10