PostgreSQL High Availablity Installation Setup with REPMGR+Automatic Failover
Table of Contents
On Primary:
On Standby Nodes:
On ALL Nodes:
1. Overview
What is repmgr
This setup provides controlled automation, similar in function to Oracle Data Guard Broker with Fast-Start Failover, enabling reliable and fast recovery in PostgreSQL environments.
repmgr (Replication Manager) is an open-source tool used to manage PostgreSQL streaming replication clusters.
It automates setup, monitoring, failover, and switchover between primary and standby nodes. Similar to the role of Data Guard Broker in Oracle environments.
The repmgrd daemon for Automatic failover, it acts like Oracle’s Fast-Start Failover (FSFO) feature.
It continuously monitors the primary database, and when it becomes unreachable, repmgrd automatically promotes the most suitable standby based on defined priorities and health checks.
Core Components
| Component | Description |
|---|
| repmgr.conf | Config file on each node describing connection info, node ID, etc. |
| repmgr database | Stores metadata of cluster state (which node is master, which are standbys). |
| repmgr CLI | Command-line tool for admin actions (clone, register, promote, show cluster). |
| repmgrd daemon | Background service that monitors nodes and can trigger automatic failover. |
How Failover Works
| Step | Description |
|---|
| 1 | Continuous Monitoring: repmgrd on standby continuously monitors the primary via PostgreSQL connection. |
| 2 | Reconnection Attempts: If the primary is unreachable, retries reconnect_attempts=6 × reconnect_interval=3 (18 seconds) before declaring it down. |
| 3 | SSH Verification (Optional): repmgrd may connect to the primary via SSH to check its actual state before taking any action, using commands like pg_isready or repmgr cluster show. |
| 4 | Stopping Services to Prevent Split-Brain: If the primary is still running but unreachable and another standby has promoted itself, repmgrd stops PostgreSQL and repmgrd services on the old primary:
service_stop_command='sudo /usr/bin/systemctl stop postgresql-17.service'
repmgrd_service_stop_command='sudo /usr/bin/systemctl stop repmgr-17.service' |
| 5 | Consensus Settings Check (3+ nodes): primary_visibility_consensus=true ensures majority agreement before initiating failover. |
| 6 | Failover Decision: If confirmed down and replication_lag_critical=600, the standby with the highest node_priority promotes itself (if failover=automatic). |
| 7 | Promotion Execution: Executed using promote_command='/usr/pgsql-17/bin/repmgr standby promote -f /etc/repmgr/17/repmgr.conf --log-to-file'. |
| 8 | During Promotion: The promoting standby manages PostgreSQL locally. Other nodes may use SSH commands to restart or reload services if needed. |
| 9 | Post-Failover Follow: Remaining standbys follow the new primary using follow_command='/usr/pgsql-17/bin/repmgr standby follow -f /etc/repmgr/17/repmgr.conf --log-to-file --upstream-node-id=%n'. |
| 10 | Service Synchronization: Standbys may restart or reload PostgreSQL and repmgrd services to ensure replication is active and synchronized with the new primary. |
| 11 | Manual Maintenance / Switchover: Commands like repmgr standby switchover or repmgr cluster cleanup can stop, start, or reload services on remote nodes automatically via SSH. |
| 12 | Original Primary Returns & Reintegration: The old primary does not become primary automatically. It must be demoted and rejoined as a standby using repmgr node rejoin, fetching missing WALs to synchronize with the new primary and avoid split-brain. |
Advantages of repmgr
- Simplicity: Simplifies configuration of streaming replication (no manual pg_basebackup, no editing of recovery files). One command can clone and register standbys.
- Lightweight: No license cost, works with standard PostgreSQL binaries, Easy to install and manage.
- Flexible deployment: Works on bare-metal, VMs, or containers.
- CLI automation: Simplifies cloning, registering, failover, and switchover.
Disadvantages / Limitations
- No built-in load balancing: You still need an external load balancer (like HAProxy, pgpool-II, or VIP scripts).
- Failover not quorum-based: Simple failover detection — risk of split-brain if network partitions occur. (You can mitigate with fencing or monitoring tools.)
- No automatic rejoin: After a node recovers, you must manually re-clone or re-register it.
Repmgr Commands Reference
| Command | Description |
|---|
| repmgr primary register | Initialise a repmgr installation and register the primary node |
| repmgr primary unregister | Unregister an inactive primary node |
| repmgr standby clone | Clone a PostgreSQL standby node from another PostgreSQL node |
| repmgr standby register | Add a standby’s information to the repmgr metadata |
| repmgr standby unregister | Remove a standby’s information from the repmgr metadata |
| repmgr standby promote | Promote a standby to a primary |
| repmgr standby follow | Attach a running standby to a new upstream node |
| repmgr standby switchover | Promote a standby to primary and demote the existing primary to a standby |
| repmgr witness register | Add a witness node’s information to the repmgr metadata |
| repmgr witness unregister | Remove a witness node’s information from the repmgr metadata |
| repmgr node status | Show overview of a node’s basic information and replication status |
| repmgr node check | Performs health checks on a node from a replication perspective |
| repmgr node rejoin | Rejoin a dormant (stopped) node to the replication cluster |
| repmgr node service | Show or execute system service commands to stop/start/restart/reload/promote a node |
| repmgr cluster show | Display information about each registered node in the replication cluster |
| repmgr cluster matrix | Run repmgr cluster show on each node and summarize output |
| repmgr cluster crosscheck | Cross-check connections between each combination of nodes |
| repmgr cluster event | Output a formatted list of cluster events |
| repmgr cluster cleanup | Purge monitoring history |
| repmgr service status | Display information about the status of repmgrd on each node |
| repmgr service pause | Instruct all repmgrd instances in the replication cluster to pause failover operations |
| repmgr service unpause | Instruct all repmgrd instances in the replication cluster to resume failover operations |
| repmgr daemon start | Start the repmgrd daemon on the local node |
| repmgr daemon stop | Stop the repmgrd daemon on the local node |
2. Environment Setup
| Node | Role | Hostname | IP | PostgreSQL Version | REPMGR Version | PostgreSQL Port |
|---|
| Node1 | Primary | rac1 | 192.168.2.21 | PostgreSQL v17 | REPMGR v17 | 5432 |
| Node2 | Standby 1 | rac2 | 192.168.2.22 | PostgreSQL v17 | REPMGR v17 | 5432 |
| Node3 | Standby 2 | rac3 | 192.168.3.20 | PostgreSQL v17 | REPMGR v17 | 5432 |
3. Pre-requisites
The following software must be installed on master and on all standby servers.
1. Install PostgreSQL on All Nodes (I have already installed same version 17.6 in the all the servers)
2. Repmgr (Should be match with PostgreSQL major version)
3. Firewall enabled and allow (Done)
4. Passwordless SSH is required between cluster nodes. (Done)
The PostgreSQL OS user (e.g., postgres) must have sudo privileges to execute those service commands without prompting for a password.
If SSH isn’t configured, repmgr can still work — but it won’t be able to manage services on other nodes automatically.
4. Install repmgr on All Nodes
4.1 Primary (rac1)
[root@rac1 ~]# dnf install -y repmgr_17
enterprisedb-enterprise 480 B/s | 659 B 00:01
enterprisedb-enterprise-noarch 711 B/s | 659 B 00:00
enterprisedb-enterprise-source 797 B/s | 659 B 00:00
Dependencies resolved.
====================================================================================================================================================
Package Architecture Version Repository Size
====================================================================================================================================================
Installing:
repmgr_17 x86_64 5.5.0-1PGDG.rhel8 pgdg17 295 k
Transaction Summary
====================================================================================================================================================
Install 1 Package
Total download size: 295 k
Installed size: 1.1 M
Downloading Packages:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64.rpm 414 kB/s | 295 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total 410 kB/s | 295 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installing : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Verifying : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installed:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64
Complete!
[root@rac1 ~]#
4.2 Standby 1 (rac2)
[root@rac2 ~]# dnf install -y repmgr_17
enterprisedb-enterprise 381 B/s | 659 B 00:01
enterprisedb-enterprise-noarch 581 B/s | 659 B 00:01
enterprisedb-enterprise-source 685 B/s | 659 B 00:00
Dependencies resolved.
====================================================================================================================================================
Package Architecture Version Repository Size
====================================================================================================================================================
Installing:
repmgr_17 x86_64 5.5.0-1PGDG.rhel8 pgdg17 295 k
Transaction Summary
====================================================================================================================================================
Install 1 Package
Total download size: 295 k
Installed size: 1.1 M
Downloading Packages:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64.rpm 2.6 MB/s | 295 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total 2.5 MB/s | 295 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installing : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Verifying : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installed:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64
Complete!
[root@rac2 ~]#
4.3 Standby 2 (rac3)
[root@rac3 ~]# dnf install -y repmgr_17
enterprisedb-enterprise 426 B/s | 659 B 00:01
enterprisedb-enterprise-noarch 740 B/s | 659 B 00:00
enterprisedb-enterprise-source 742 B/s | 659 B 00:00
Dependencies resolved.
====================================================================================================================================================
Package Architecture Version Repository Size
====================================================================================================================================================
Installing:
repmgr_17 x86_64 5.5.0-1PGDG.rhel8 pgdg17 295 k
Transaction Summary
====================================================================================================================================================
Install 1 Package
Total download size: 295 k
Installed size: 1.1 M
Downloading Packages:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64.rpm 744 kB/s | 295 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------
Total 733 kB/s | 295 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installing : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Running scriptlet: repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Verifying : repmgr_17-5.5.0-1PGDG.rhel8.x86_64 1/1
Installed:
repmgr_17-5.5.0-1PGDG.rhel8.x86_64
Complete!
[root@rac3 ~]#
On Primary:
5. Configure postgresql.conf (Primary)
# Add below entries /pgData/pgsql17/data/postgresql.conf
listen_addresses = '0.0.0.0' # ipv4 only
max_wal_senders = 10
max_replication_slots = 10
wal_level = 'replica'
hot_standby = on
archive_mode = on
archive_command = 'cp %p /pgArch/pgsql17/arch/%f'
shared_preload_libraries = 'repmgr'
wal_log_hints = on
wal_keep_size = 64
password_encryption ='scram-sha-256'
6. Create repmgr User and Database (Primary)
postgres=# CREATE USER repmgr SUPERUSER LOGIN PASSWORD 'repmgr';
CREATE ROLE
postgres=# CREATE DATABASE repmgr OWNER repmgr;
CREATE DATABASE
postgres=#
postgres=# ALTER USER repmgr CREATEROLE;
ALTER ROLE
postgres=# ALTER USER repmgr CREATEDB;
ALTER ROLE
postgres=#
postgres=# \l
List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules | Access privileges
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------
postgres | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | |
repmgr | repmgr | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | |
template0 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | =c/postgres +
| | | | | | | | postgres=CTc/postgres
(4 rows)
postgres=#
postgres=# \du
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
repmgr | Superuser, Create role, Create DB
postgres=#
7. Configure pg_hba.conf (Primary)
[postgres@rac1 ~]$ tail -11 /pgData/pgsql17/data/pg_hba.conf
# For replication connections
local replication repmgr scram-sha-256
host replication repmgr 127.0.0.1/32 scram-sha-256
host replication repmgr 192.168.2.21/32 scram-sha-256
host replication repmgr 192.168.2.22/32 scram-sha-256
host replication repmgr 192.168.3.20/32 scram-sha-256
# For database connections to repmgr database
local repmgr repmgr scram-sha-256
host repmgr repmgr 127.0.0.1/32 scram-sha-256
host repmgr repmgr 192.168.2.21/32 scram-sha-256
host repmgr repmgr 192.168.2.22/32 scram-sha-256
host repmgr repmgr 192.168.3.20/32 scram-sha-256
[postgres@rac1 ~]$
8. Create /home/postgres/.pgpass file to keep REPMGR password
# The database automatically reads passwords from the .pgpass file during startup, login, switchover, or failover, hence no need to enter manually.
[postgres@rac1 ~]$ cat /home/postgres/.pgpass
# hostname:port:database:user:password
# Repmgr user
rac1:5432:*:repmgr:repmgr123
rac2:5432:*:repmgr:repmgr123
rac3:5432:*:repmgr:repmgr123
# postgres user
rac1:5432:*:postgres:oracle
rac2:5432:*:postgres:oracle
rac3:5432:*:postgres:oracle
[postgres@rac1 ~]$
9. Restart PostgreSQL
[root@rac1 ~]# systemctl stop postgresql-17.service
[root@rac1 ~]# systemctl start postgresql-17.service
[root@rac1 ~]#
10. Configure repmgr.conf (Primary)
[root@rac1 ~]# ls -ltr /etc/repmgr/17/repmgr.conf
-rw-r--r--. 1 root root 21586 Nov 23 2024 /etc/repmgr/17/repmgr.conf
[root@rac1 ~]#
[root@rac1 ~]# mv /etc/repmgr/17/repmgr.conf /etc/repmgr/17/repmgr.conf.bkp
[root@rac1 ~]#
[root@rac1 ~]# ls -ld /pgData/pgsql17/pgerror/repmgr/log/
drwxr-xr-x. 2 postgres postgres 24 Oct 22 08:02 /pgData/pgsql17/pgerror/repmgr/log/
[root@rac1 ~]#
#Add below entries to /etc/repmgr/17/repmgr.conf as root user
# Please make sure create directory /pgData/pgsql17/pgerror/repmgr/log
[root@rac1 ~]# cat /etc/repmgr/17/repmgr.conf
# Basic Cluster Settings
node_id=1
node_name='rac1'
conninfo='host=rac1 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/pgData/pgsql17/data'
passfile='/home/postgres/.pgpass' # if password file in custom location
# Backup, Binary, Logging
pg_basebackup_options='--checkpoint=fast --waldir=/pgWal/pgsql17/wal'
pg_bindir='/usr/pgsql-17/bin/'
log_file='/pgData/pgsql17/pgerror/repmgr/log/repmgr.log'
# Failover & Promotion
failover=automatic
promote_command='/usr/pgsql-17/bin/repmgr standby promote -f /etc/repmgr/17/repmgr.conf --log-to-file'
follow_command='/usr/pgsql-17/bin/repmgr standby follow -f /etc/repmgr/17/repmgr.conf --log-to-file --upstream-node-id=%n'
# Replication and Slots
use_replication_slots=true
# Split-brain protection # Consensus settings
primary_visibility_consensus=true # Use true for 3 or more node setups, not for 2 node setup.
# Logging & Monitoring in seconds
#log_level='NOTICE' # Logs important events, warnings, and errors.
log_status_interval=300 # Every 5 minutes, repmgrd will write a status message to the log file.
replication_lag_critical=600 # If a standby lag is 600 seconds (10 minutes) behind, The standby will NOT promote — to avoid data loss.
monitoring_history=yes # Stores cluster monitoring data in the database for auditing and diagnostics
# Failover promotion priority (higher = more preferred)
#priority=100
# Optional but helpful (for automation):
ssh_options='-q -o ConnectTimeout=10'
# Service commands (via SSH) allow remote control of PostgreSQL and repmgrd
# For repmgrd service on remote node
repmgrd_service_start_command='sudo /usr/bin/systemctl start repmgr-17.service'
repmgrd_service_stop_command='sudo /usr/bin/systemctl stop repmgr-17.service'
# For PostgreSQL service on remote node
service_start_command='sudo /usr/bin/systemctl start postgresql-17.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql-17.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql-17.service'
service_reload_command='sudo /usr/bin/systemctl reload postgresql-17.service'
# if you would have done installation using source code or Tar ball, then use pg_ctl instead of systemctl
#service_start_command='/usr/pgsql-17/bin/pg_ctl -D /pgData/pgsql17/data start'
#service_stop_command='/usr/pgsql-17/bin/pg_ctl -D /pgData/pgsql17/data stop'
#service_restart_command='/usr/pgsql-17/bin/pg_ctl -D /pgData/pgsql17/data restart'
#service_reload_command='/usr/pgsql-17/bin/pg_ctl -D /pgData/pgsql17/data reload'
[root@rac1 ~]#
11. Test the connectivity
[postgres@rac1 ~]$ psql "host=rac1 user=repmgr dbname=repmgr connect_timeout=2"
psql (17.6)
Type "help" for help.
repmgr=# exit
[postgres@rac1 ~]$
12. Register Primary Node (Primary)
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr primary register -f /etc/repmgr/17/repmgr.conf
INFO: connecting to primary database...
NOTICE: attempting to install extension "repmgr"
NOTICE: "repmgr" extension successfully installed
NOTICE: primary node record (ID: 1) registered
[postgres@rac1 ~]$
13. Verify Cluster Status
[postgres@rac1 ~]$ psql -U repmgr -d repmgr
psql (17.6)
Type "help" for help.
repmgr=# select * from repmgr.nodes;
node_id | upstream_node_id | active | node_name | type | location | priority | conninfo | repluser | slot_name | config_file
---------+------------------+--------+-----------+---------+----------+----------+-------------------------------------------------------+----------+---------------+----------------------------
1 | | t | rac1 | primary | default | 100 | host=rac1 user=repmgr dbname=repmgr connect_timeout=2 | repmgr | repmgr_slot_1 | /etc/repmgr/17/repmgr.conf
(1 row)
repmgr=#
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+------+---------+-----------+----------+----------+----------+----------+-------------------------------------------------------
1 | rac1 | primary | * running | | default | 100 | 3 | host=rac1 user=repmgr dbname=repmgr connect_timeout=2
[postgres@rac1 ~]$
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr cluster event
Node ID | Name | Event | OK | Timestamp | Details
---------+------+------------------+----+---------------------+---------
1 | rac1 | primary_register | t | 2025-10-22 01:55:20 |
1 | rac1 | primary_register | t | 2025-10-22 01:49:13 |
1 | rac1 | cluster_created | t | 2025-10-22 01:49:13 |
[postgres@rac1 ~]$
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr cluster crosscheck
INFO: connecting to database
Name | ID | 1
------+----+---
rac1 | 1 | *
[postgres@rac1 ~]$
On Standby Nodes:
14. Create /home/postgres/.pgpass file to keep REPMGR password
14.1 Standby 1 (rac2)
# The database automatically reads passwords from the .pgpass file during startup, login, switchover, or failover, hence no need to enter manually.
# owner postgres:Postgres
# 0600 permission must, else password won't read
[postgres@rac2 ~]$ ls -ltra /home/postgres/.pgpass
-rw-------. 1 postgres postgres 228 Oct 22 02:45 /home/postgres/.pgpass
[postgres@rac2 ~]$
[postgres@rac2 ~]$ cat /home/postgres/.pgpass
# hostname:port:database:user:password
# Repmgr user
rac1:5432:*:repmgr:repmgr123
rac2:5432:*:repmgr:repmgr123
rac3:5432:*:repmgr:repmgr123
# postgres user
rac1:5432:*:postgres:oracle
rac2:5432:*:postgres:oracle
rac3:5432:*:postgres:oracle
[postgres@rac2 ~]$
[postgres@rac2 ~]$ psql -h rac1 -U repmgr -d repmgr
psql (17.6)
Type "help" for help.
repmgr=# exit
[postgres@rac2 ~]$
14.2 Standby 2 (rac3)
# The database automatically reads passwords from the .pgpass file during startup, login, switchover, or failover, hence no need to enter manually.
[postgres@rac3 ~]$ ls -ltra /home/postgres/.pgpass
-rw-------. 1 postgres postgres 228 Oct 22 02:45 /home/postgres/.pgpass
[postgres@rac3 ~]$
[postgres@rac3 ~]$ cat /home/postgres/.pgpass
# hostname:port:database:user:password
# Repmgr user
rac1:5432:*:repmgr:repmgr123
rac2:5432:*:repmgr:repmgr123
rac3:5432:*:repmgr:repmgr123
# postgres user
rac1:5432:*:postgres:oracle
rac2:5432:*:postgres:oracle
rac3:5432:*:postgres:oracle
[postgres@rac3 ~]$
[postgres@rac3 ~]$ psql -h rac1 -U repmgr -d repmgr
psql (17.6)
Type "help" for help.
repmgr=# exit
[postgres@rac3 ~]$
15. Remove All content from PGDATA/WAL/WAL Archives (All Standby)
15.1 Standby 1 (rac2)
[postgres@rac2 ~]$ rm -rf /pgData/pgsql17/data/*
[postgres@rac2 ~]$ rm -rf /pgWal/pgsql17/wal/*
[postgres@rac2 ~]$ rm -rf /pgArch/pgsql17/arch/*
[postgres@rac2 ~]$
15.2 Standby 2 (rac3)
[postgres@rac3 ~]$ rm -rf /pgData/pgsql17/data/*
[postgres@rac3 ~]$ rm -rf /pgWal/pgsql17/wal/*
[postgres@rac3 ~]$ rm -rf /pgArch/pgsql17/arch/*
[postgres@rac3 ~]$
16. Configure repmgr.conf (All Standby)
16.1 Standby 1 (rac2)
[root@rac2 ~]# ls -ltr /etc/repmgr/17/repmgr.conf
-rw-r--r--. 1 root root 21586 Nov 23 2024 /etc/repmgr/17/repmgr.conf
[root@rac2 ~]# mv /etc/repmgr/17/repmgr.conf /etc/repmgr/17/repmgr.conf.bkp
[root@rac2 ~]#
[root@rac2 ~]# ls -ld /pgData/pgsql17/pgerror/repmgr/log/
drwxr-xr-x. 2 postgres postgres 24 Oct 22 08:23 /pgData/pgsql17/pgerror/repmgr/log/
[root@rac2 ~]#
# Add below entries to /etc/repmgr/17/repmgr.conf
# Please make sure create directory /pgData/pgsql17/pgerror/repmgr/log
[root@rac2 ~]# cat /etc/repmgr/17/repmgr.conf
# Basic Cluster Settings
node_id=2
node_name='rac2'
conninfo='host=rac2 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/pgData/pgsql17/data'
passfile='/home/postgres/.pgpass' # if password file in custom location
# Backup, Binary, Logging
pg_basebackup_options='--checkpoint=fast --waldir=/pgWal/pgsql17/wal'
pg_bindir='/usr/pgsql-17/bin/'
log_file='/pgData/pgsql17/pgerror/repmgr/log/repmgr.log'
# Failover & Promotion
failover=automatic
promote_command='/usr/pgsql-17/bin/repmgr standby promote -f /etc/repmgr/17/repmgr.conf --log-to-file'
follow_command='/usr/pgsql-17/bin/repmgr standby follow -f /etc/repmgr/17/repmgr.conf --log-to-file --upstream-node-id=%n'
# Replication and Slots
use_replication_slots=true
# Split-brain protection # Consensus settings
primary_visibility_consensus=true # Use true for 3 or more node setups, not for 2 node setup.
# Logging & Monitoring in seconds
#log_level='NOTICE' # Logs important events, warnings, and errors.
log_status_interval=300 # Every 5 minutes, repmgrd will write a status message to the log file.
replication_lag_critical=600 # If a standby lag is 600 seconds (10 minutes) behind, The standby will NOT promote — to avoid data loss.
monitoring_history=yes # Stores cluster monitoring data in the database for auditing and diagnostics
# Failover promotion priority (higher = more preferred)
#priority=100
# Optional but helpful (for automation):
ssh_options='-q -o ConnectTimeout=10'
# Service commands (via SSH) allow remote control of PostgreSQL and repmgrd
# For repmgrd service on remote node
repmgrd_service_start_command='sudo /usr/bin/systemctl start repmgr-17.service'
repmgrd_service_stop_command='sudo /usr/bin/systemctl stop repmgr-17.service'
# For PostgreSQL service on remote node
service_start_command='sudo /usr/bin/systemctl start postgresql-17.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql-17.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql-17.service'
service_reload_command='sudo /usr/bin/systemctl reload postgresql-17.service'
[root@rac2 ~]#
16.2 Standby 2 (rac3)
[root@rac3 ~]# ls -ltr /etc/repmgr/17/repmgr.conf
-rw-r--r--. 1 root root 21586 Nov 23 2024 /etc/repmgr/17/repmgr.conf
[root@rac3 ~]# mv /etc/repmgr/17/repmgr.conf /etc/repmgr/17/repmgr.conf.bkp
[root@rac3 ~]#
[root@rac3 ~]# ls -ld /pgData/pgsql17/pgerror/repmgr/log/
drwxr-xr-x. 2 postgres postgres 24 Oct 22 08:24 /pgData/pgsql17/pgerror/repmgr/log/
[root@rac3 ~]#
# Add below entries to /etc/repmgr/17/repmgr.conf
# Please make sure create directory /pgData/pgsql17/pgerror/repmgr/log
[root@rac3 ~]# cat /etc/repmgr/17/repmgr.conf
# Basic Cluster Settings
node_id=3
node_name='rac3'
conninfo='host=rac3 user=repmgr dbname=repmgr connect_timeout=2'
data_directory='/pgData/pgsql17/data'
passfile='/home/postgres/.pgpass' # if password file in custom location
# Backup, Binary, Logging
pg_basebackup_options='--checkpoint=fast --waldir=/pgWal/pgsql17/wal'
pg_bindir='/usr/pgsql-17/bin/'
log_file='/pgData/pgsql17/pgerror/repmgr/log/repmgr.log'
# Failover & Promotion
failover=automatic
promote_command='/usr/pgsql-17/bin/repmgr standby promote -f /etc/repmgr/17/repmgr.conf --log-to-file'
follow_command='/usr/pgsql-17/bin/repmgr standby follow -f /etc/repmgr/17/repmgr.conf --log-to-file --upstream-node-id=%n'
# Replication and Slots
use_replication_slots=true
# Split-brain protection # Consensus settings
primary_visibility_consensus=true # Use true for 3 or more node setups, not for 2 node setup.
# Logging & Monitoring in seconds
#log_level='NOTICE' # Logs important events, warnings, and errors.
log_status_interval=300 # Every 5 minutes, repmgrd will write a status message to the log file.
replication_lag_critical=600 # If a standby lag is 600 seconds (10 minutes) behind, The standby will NOT promote — to avoid data loss.
monitoring_history=yes # Stores cluster monitoring data in the database for auditing and diagnostics
# Failover promotion priority (higher = more preferred)
#priority=100
# Optional but helpful (for automation):
ssh_options='-q -o ConnectTimeout=10'
# Service commands (via SSH) allow remote control of PostgreSQL and repmgrd
# For repmgrd service on remote node
repmgrd_service_start_command='sudo /usr/bin/systemctl start repmgr-17.service'
repmgrd_service_stop_command='sudo /usr/bin/systemctl stop repmgr-17.service'
# For PostgreSQL service on remote node
service_start_command='sudo /usr/bin/systemctl start postgresql-17.service'
service_stop_command='sudo /usr/bin/systemctl stop postgresql-17.service'
service_restart_command='sudo /usr/bin/systemctl restart postgresql-17.service'
service_reload_command='sudo /usr/bin/systemctl reload postgresql-17.service'
[root@rac3 ~]#
17. Clone dry-run test on Standby Nodes
17.1 Standby 1 (rac2)
[root@rac2 ~]# su - postgres
[postgres@rac2 ~]$ /usr/pgsql-17/bin/repmgr -h rac1 -U repmgr -d repmgr standby clone --dry-run
NOTICE: destination directory "/pgData/pgsql17/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=rac1 user=repmgr dbname=repmgr
DETAIL: current installation size is 30 MB
INFO: "repmgr" extension is installed in database "repmgr"
INFO: parameter "max_replication_slots" set to 10
INFO: parameter "max_wal_senders" set to 10
NOTICE: checking for available walsenders on the source node (2 required)
INFO: sufficient walsenders available on the source node
DETAIL: 2 required, 10 available
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: required number of replication connections could be made to the source server
DETAIL: 2 replication connections required
INFO: replication slots will be created by user "repmgr"
NOTICE: standby will attach to upstream node 1
HINT: consider using the -c/--fast-checkpoint option
INFO: would execute:
/usr/pgsql-17/bin/pg_basebackup -l "repmgr base backup" -D /pgData/pgsql17/data -h rac1 -p 5432 -U repmgr -X stream -S repmgr_slot_2 --checkpoint=fast --waldir=/pgWal/pgsql17/wal
INFO: all prerequisites for "standby clone" are met <----
[postgres@rac2 ~]$
17.2 Standby 2 (rac3)
[postgres@rac3 ~]$ /usr/pgsql-17/bin/repmgr -h rac1 -U repmgr -d repmgr standby clone --dry-run
NOTICE: destination directory "/pgData/pgsql17/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=rac1 user=repmgr dbname=repmgr
DETAIL: current installation size is 30 MB
INFO: "repmgr" extension is installed in database "repmgr"
INFO: parameter "max_replication_slots" set to 10
INFO: parameter "max_wal_senders" set to 10
NOTICE: checking for available walsenders on the source node (2 required)
INFO: sufficient walsenders available on the source node
DETAIL: 2 required, 10 available
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: required number of replication connections could be made to the source server
DETAIL: 2 replication connections required
INFO: replication slots will be created by user "repmgr"
NOTICE: standby will attach to upstream node 1
HINT: consider using the -c/--fast-checkpoint option
INFO: would execute:
/usr/pgsql-17/bin/pg_basebackup -l "repmgr base backup" -D /pgData/pgsql17/data -h rac1 -p 5432 -U repmgr -X stream -S repmgr_slot_3 --checkpoint=fast --waldir=/pgWal/pgsql17/wal
INFO: all prerequisites for "standby clone" are met <----
[postgres@rac3 ~]$
18. Clone Standby Nodes
18.1 Standby 1 (rac2)
[postgres@rac2 ~]$ /usr/pgsql-17/bin/repmgr -h rac1 -U repmgr -d repmgr standby clone
NOTICE: destination directory "/pgData/pgsql17/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=rac1 user=repmgr dbname=repmgr
DETAIL: current installation size is 30 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: checking and correcting permissions on existing directory "/pgData/pgsql17/data"
NOTICE: starting backup (using pg_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
/usr/pgsql-17/bin/pg_basebackup -l "repmgr base backup" -D /pgData/pgsql17/data -h rac1 -p 5432 -U repmgr -X stream -S repmgr_slot_2 --checkpoint=fast --waldir=/pgWal/pgsql17/wal
NOTICE: standby clone (using pg_basebackup) complete <-----
NOTICE: you can now start your PostgreSQL server
HINT: for example: sudo /usr/bin/systemctl start postgresql-17.service
HINT: after starting the server, you need to register this standby with "repmgr standby register"
[postgres@rac2 ~]$
18.2 Standby 2 (rac3)
[postgres@rac3 ~]$ /usr/pgsql-17/bin/repmgr -h rac1 -U repmgr -d repmgr standby clone
NOTICE: destination directory "/pgData/pgsql17/data" provided
INFO: connecting to source node
DETAIL: connection string is: host=rac1 user=repmgr dbname=repmgr
DETAIL: current installation size is 30 MB
NOTICE: checking for available walsenders on the source node (2 required)
NOTICE: checking replication connections can be made to the source server (2 required)
INFO: checking and correcting permissions on existing directory "/pgData/pgsql17/data"
NOTICE: starting backup (using pg_basebackup)...
HINT: this may take some time; consider using the -c/--fast-checkpoint option
INFO: executing:
/usr/pgsql-17/bin/pg_basebackup -l "repmgr base backup" -D /pgData/pgsql17/data -h rac1 -p 5432 -U repmgr -X stream -S repmgr_slot_3 --checkpoint=fast --waldir=/pgWal/pgsql17/wal
NOTICE: standby clone (using pg_basebackup) complete <-----
NOTICE: you can now start your PostgreSQL server
HINT: for example: sudo /usr/bin/systemctl start postgresql-17.service
HINT: after starting the server, you need to register this standby with "repmgr standby register"
[postgres@rac3 ~]$
19. Register Standby Nodes
19.1 Standby 1 (rac2)
[root@rac2 ~]# systemctl start postgresql-17.service
[root@rac2 ~]#
[root@rac2 ~]# systemctl enable postgresql-17
[root@rac2 ~]#
[postgres@rac2 ~]$ /usr/pgsql-17/bin/repmgr standby register
INFO: connecting to local node "rac2" (ID: 2)
INFO: connecting to primary database
WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID: 1)
INFO: standby registration complete
NOTICE: standby node "rac2" (ID: 2) successfully registered
[postgres@rac2 ~]$
19.2 Standby 2 (rac3)
[root@rac3 ~]# systemctl start postgresql-17.service
[root@rac3 ~]#
[root@rac3 ~]# systemctl enable postgresql-17
[root@rac3 ~]#
[postgres@rac3 ~]$ /usr/pgsql-17/bin/repmgr standby register
INFO: connecting to local node "rac3" (ID: 3)
INFO: connecting to primary database
WARNING: --upstream-node-id not supplied, assuming upstream node is primary (node ID: 1)
INFO: standby registration complete
NOTICE: standby node "rac3" (ID: 3) successfully registered
[postgres@rac3 ~]$
On ALL Nodes:
20. Verify Cluster Status
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr cluster show
ID | Name | Role | Status | Upstream | Location | Priority | Timeline | Connection string
----+------+---------+-----------+----------+----------+----------+----------+-------------------------------------------------------
1 | rac1 | primary | * running | | default | 100 | 3 | host=rac1 user=repmgr dbname=repmgr connect_timeout=2
2 | rac2 | standby | running | rac1 | default | 100 | 3 | host=rac2 user=repmgr dbname=repmgr connect_timeout=2
3 | rac3 | standby | running | rac1 | default | 100 | 3 | host=rac3 user=repmgr dbname=repmgr connect_timeout=2
[postgres@rac1 ~]$
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr cluster crosscheck
INFO: connecting to database
Name | ID | 1 | 2 | 3
------+----+---+---+---
rac1 | 1 | * | * | *
rac2 | 2 | * | * | *
rac3 | 3 | * | * | *
[postgres@rac1 ~]$
[postgres@rac1 ~]$ ps -ef | grep repmgr
postgres 9034 8961 0 07:27 ? 00:00:00 postgres: walsender repmgr 192.168.2.22(57044) streaming 0/45001DB8
postgres 9261 8961 0 07:40 ? 00:00:00 postgres: walsender repmgr 192.168.3.20(38040) streaming 0/45001DB8
postgres 9949 9887 0 08:01 pts/0 00:00:00 grep --color=auto repmgr
[postgres@rac1 ~]$
21. Enable and auto start repmgr-17.service
21.1 Primary (rac1)
[root@rac1 ~]# ls -ltr /usr/pgsql-17/bin/repmgr*
-rwxr-xr-x. 1 root root 331480 Nov 23 2024 /usr/pgsql-17/bin/repmgrd
-rwxr-xr-x. 1 root root 573376 Nov 23 2024 /usr/pgsql-17/bin/repmgr
[root@rac1 ~]#
[root@rac1 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@rac1 ~]#
[root@rac1 ~]# systemctl enable repmgr-17.service
Created symlink /etc/systemd/system/multi-user.target.wants/repmgr-17.service → /usr/lib/systemd/system/repmgr-17.service.
[root@rac1 ~]#
[root@rac1 ~]# systemctl start repmgr-17.service
[root@rac1 ~]#
[root@rac1 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2025-10-22 08:26:43 EDT; 9s ago
Process: 11199 ExecStop=/usr/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 11212 ExecStart=/usr/pgsql-17/bin/repmgrd -f ${REPMGRDCONF} -p ${PIDFILE} -d --verbose (cod>
Main PID: 11215 (repmgrd)
Tasks: 1 (limit: 16808)
Memory: 1.3M
CGroup: /system.slice/repmgr-17.service
└─11215 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.p>
Oct 22 08:26:43 rac1.rajasekhar.com systemd[1]: Starting A replication manager, and failover managemen>
Oct 22 08:26:43 rac1.rajasekhar.com repmgrd[11212]: [2025-10-22 08:26:43] [NOTICE] using provided conf>
Oct 22 08:26:43 rac1.rajasekhar.com repmgrd[11212]: [2025-10-22 08:26:43] [NOTICE] redirecting logging>
Oct 22 08:26:43 rac1.rajasekhar.com systemd[1]: repmgr-17.service: Can't open PID file /run/repmgr/rep>
Oct 22 08:26:43 rac1.rajasekhar.com systemd[1]: Started A replication manager, and failover management>
[root@rac1 ~]#
21.2 Standby 1 (rac2)
[root@rac2 ~]# ls -ltr /usr/pgsql-17/bin/repmgr*
-rwxr-xr-x. 1 root root 331480 Nov 23 2024 /usr/pgsql-17/bin/repmgrd
-rwxr-xr-x. 1 root root 573376 Nov 23 2024 /usr/pgsql-17/bin/repmgr
[root@rac2 ~]#
[root@rac2 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@rac2 ~]#
[root@rac2 ~]# systemctl enable repmgr-17.service
Created symlink /etc/systemd/system/multi-user.target.wants/repmgr-17.service → /usr/lib/systemd/system/repmgr-17.service.
[root@rac2 ~]#
[root@rac2 ~]# systemctl start repmgr-17.service
[root@rac2 ~]#
[root@rac2 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2025-10-22 08:26:43 EDT; 9s ago
Process: 10525 ExecStop=/usr/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 10538 ExecStart=/usr/pgsql-17/bin/repmgrd -f ${REPMGRDCONF} -p ${PIDFILE} -d --verbose (cod>
Main PID: 10541 (repmgrd)
Tasks: 1 (limit: 16808)
Memory: 1.3M
CGroup: /system.slice/repmgr-17.service
└─10541 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.p>
Oct 22 08:26:43 rac2.rajasekhar.com systemd[1]: Starting A replication manager, and failover managemen>
Oct 22 08:26:43 rac2.rajasekhar.com repmgrd[10538]: [2025-10-22 08:26:43] [NOTICE] using provided conf>
Oct 22 08:26:43 rac2.rajasekhar.com repmgrd[10538]: [2025-10-22 08:26:43] [NOTICE] redirecting logging>
Oct 22 08:26:43 rac2.rajasekhar.com systemd[1]: repmgr-17.service: Can't open PID file /run/repmgr/rep>
Oct 22 08:26:43 rac2.rajasekhar.com systemd[1]: Started A replication manager, and failover management>
[root@rac2 ~]#
21.3 Standby 2 (rac3)
[root@rac3 ~]# ls -ltr /usr/pgsql-17/bin/repmgr*
-rwxr-xr-x. 1 root root 331480 Nov 23 2024 /usr/pgsql-17/bin/repmgrd
-rwxr-xr-x. 1 root root 573376 Nov 23 2024 /usr/pgsql-17/bin/repmgr
[root@rac3 ~]#
[root@rac3 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@rac3 ~]#
[root@rac3 ~]# systemctl enable repmgr-17.service
Created symlink /etc/systemd/system/multi-user.target.wants/repmgr-17.service → /usr/lib/systemd/system/repmgr-17.service.
[root@rac3 ~]#
[root@rac3 ~]# systemctl start repmgr-17.service
[root@rac3 ~]#
[root@rac3 ~]# systemctl status repmgr-17.service
● repmgr-17.service - A replication manager, and failover management tool for PostgreSQL
Loaded: loaded (/usr/lib/systemd/system/repmgr-17.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2025-10-22 08:26:43 EDT; 9s ago
Process: 8066 ExecStop=/usr/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS)
Process: 8071 ExecStart=/usr/pgsql-17/bin/repmgrd -f ${REPMGRDCONF} -p ${PIDFILE} -d --verbose (code>
Main PID: 8074 (repmgrd)
Tasks: 1 (limit: 16808)
Memory: 1.3M
CGroup: /system.slice/repmgr-17.service
└─8074 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.pi>
Oct 22 08:26:43 rac3.rajasekhar.com systemd[1]: Starting A replication manager, and failover managemen>
Oct 22 08:26:43 rac3.rajasekhar.com repmgrd[8071]: [2025-10-22 08:26:43] [NOTICE] using provided confi>
Oct 22 08:26:43 rac3.rajasekhar.com repmgrd[8071]: [2025-10-22 08:26:43] [NOTICE] redirecting logging >
Oct 22 08:26:43 rac3.rajasekhar.com systemd[1]: repmgr-17.service: Can't open PID file /run/repmgr/rep>
Oct 22 08:26:43 rac3.rajasekhar.com systemd[1]: Started A replication manager, and failover management>
[root@rac3 ~]#
22. Verify repmgrd Daemon
22.1 Primary (rac1)
To enable the automatic failover, we now need to start the repmgrd daemon process on master, all slaves and witness if have.
# If any issue then only try to start manually /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf
17.1 Prmary (rac1)
[postgres@rac1 ~]$ /usr/pgsql-17/bin/repmgr -f /etc/repmgr/17/repmgr.conf daemon status
ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+------+---------+-----------+----------+---------+-------+---------+--------------------
1 | rac1 | primary | * running | | running | 11215 | no | n/a
2 | rac2 | standby | running | rac1 | running | 10541 | no | 0 second(s) ago
3 | rac3 | standby | running | rac1 | running | 8074 | no | 1 second(s) ago
[postgres@rac1 ~]$
[postgres@rac1 ~]$ ps -ef | grep repmgr
postgres 9034 8961 0 07:27 ? 00:00:00 postgres: walsender repmgr 192.168.2.22(57044) streaming 0/450738A0
postgres 9261 8961 0 07:40 ? 00:00:00 postgres: walsender repmgr 192.168.3.20(38040) streaming 0/450738A0
postgres 11213 8961 0 08:26 ? 00:00:00 postgres: repmgr repmgr 192.168.2.21(33864) idle
postgres 11215 1 0 08:26 ? 00:00:07 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.pid -d --verbose
postgres 11216 8961 0 08:26 ? 00:00:00 postgres: repmgr repmgr 192.168.2.22(52798) idle
postgres 11217 8961 0 08:26 ? 00:00:00 postgres: repmgr repmgr 192.168.3.20(48864) idle
postgres 12819 12248 0 08:41 pts/0 00:00:00 grep --color=auto repmgr
[postgres@rac1 ~]$
[postgres@rac1 ~]$ cat /pgData/pgsql17/pgerror/repmgr/log/repmgr.log
..
[2025-10-22 08:26:43] [NOTICE] repmgrd (repmgrd 5.5.0) starting up
[2025-10-22 08:26:43] [INFO] connecting to database "host=rac1 user=repmgr dbname=repmgr connect_timeout=2"
INFO: set_repmgrd_pid(): provided pidfile is /run/repmgr/repmgrd-17.pid
[2025-10-22 08:26:43] [NOTICE] starting monitoring of node "rac1" (ID: 1)
[2025-10-22 08:26:43] [INFO] "connection_check_type" set to "ping"
[2025-10-22 08:26:43] [NOTICE] monitoring cluster primary "rac1" (ID: 1)
[2025-10-22 08:26:43] [INFO] child node "rac2" (ID: 2) is attached
[2025-10-22 08:26:43] [INFO] child node "rac3" (ID: 3) is attached
22.2 Standby 1 (rac2)
[postgres@rac2 ~]$ ps -ef | grep repmgr
postgres 10539 9198 0 08:26 ? 00:00:00 postgres: repmgr repmgr 192.168.2.22(60154) idle
postgres 10541 1 1 08:26 ? 00:00:14 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.pid -d --verbose
postgres 11296 11010 0 08:42 pts/1 00:00:00 grep --color=auto repmgr
[postgres@rac2 ~]$
[postgres@rac2 ~]$ cat /pgData/pgsql17/pgerror/repmgr/log/repmgr.log
..
[2025-10-22 08:26:43] [NOTICE] repmgrd (repmgrd 5.5.0) starting up
[2025-10-22 08:26:43] [INFO] connecting to database "host=rac2 user=repmgr dbname=repmgr connect_timeout=2"
INFO: set_repmgrd_pid(): provided pidfile is /run/repmgr/repmgrd-17.pid
[2025-10-22 08:26:43] [NOTICE] starting monitoring of node "rac2" (ID: 2)
[2025-10-22 08:26:43] [INFO] "connection_check_type" set to "ping"
[2025-10-22 08:26:43] [INFO] monitoring connection to upstream node "rac1" (ID: 1)
[2025-10-22 08:31:44] [INFO] node "rac2" (ID: 2) monitoring upstream node "rac1" (ID: 1) in normal state
[2025-10-22 08:31:44] [DETAIL] last monitoring statistics update was 2 seconds ago
22.3 Standby 2 (rac3)
[postgres@rac3 ~]$ ps -ef | grep repmgr
postgres 8072 6903 0 08:26 ? 00:00:00 postgres: repmgr repmgr 192.168.3.20(54628) idle
postgres 8074 1 1 08:26 ? 00:00:14 /usr/pgsql-17/bin/repmgrd -f /etc/repmgr/17/repmgr.conf -p /run/repmgr/repmgrd-17.pid -d --verbose
postgres 8822 8518 0 08:42 pts/0 00:00:00 grep --color=auto repmgr
[postgres@rac3 ~]$
[postgres@rac3 ~]$ cat /pgData/pgsql17/pgerror/repmgr/log/repmgr.log
..
[2025-10-22 08:26:43] [NOTICE] repmgrd (repmgrd 5.5.0) starting up
[2025-10-22 08:26:43] [INFO] connecting to database "host=rac3 user=repmgr dbname=repmgr connect_timeout=2"
INFO: set_repmgrd_pid(): provided pidfile is /run/repmgr/repmgrd-17.pid
[2025-10-22 08:26:43] [NOTICE] starting monitoring of node "rac3" (ID: 3)
[2025-10-22 08:26:43] [INFO] "connection_check_type" set to "ping"
[2025-10-22 08:26:43] [INFO] monitoring connection to upstream node "rac1" (ID: 1)
[2025-10-22 08:31:45] [INFO] node "rac3" (ID: 3) monitoring upstream node "rac1" (ID: 1) in normal state
[2025-10-22 08:31:45] [DETAIL] last monitoring statistics update was 2 seconds ago
23. Test Replication
23.1 Primary (rac1)
[postgres@rac1 ~]$ psql -c "SELECT application_name, state, sync_state FROM pg_stat_replication;"
application_name | state | sync_state
------------------+-----------+------------
rac2 | streaming | async
rac3 | streaming | async
(2 rows)
[postgres@rac1 ~]$
[postgres@rac1 ~]$ psql -U postgres -c "SELECT pg_is_in_recovery();"
pg_is_in_recovery
-------------------
f <---- it means primary database
(1 row)
[postgres@rac1 ~]$
[postgres@rac1 ~]$ psql -c "SELECT * FROM pg_replication_slots;"
slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn | wal_status | safe_wal_size | two_phase | inactive_since | confl
icting | invalidation_reason | failover | synced
---------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+---------------------+------------+---------------+-----------+----------------+------
-------+---------------------+----------+--------
repmgr_slot_2 | | physical | | | f | t | 9034 | | | 0/451F4B00 | | reserved | | f | |
| | f | f
repmgr_slot_3 | | physical | | | f | t | 9261 | | | 0/451F4B00 | | reserved | | f | |
| | f | f
(2 rows)
[postgres@rac1 ~]$
[postgres@rac1 ~]$ psql -c "CREATE TABLE emp (name TEXT, designation TEXT, project TEXT, company TEXT);"
CREATE TABLE
[postgres@rac1 ~]$
[postgres@rac1 ~]$ psql -c "INSERT INTO emp VALUES ('Sugi', 'DBA', 'Jetstar', 'iGATE');"
INSERT 0 1
[postgres@rac1 ~]$ psql -c "INSERT INTO emp VALUES ('Teja', 'DBA', 'RCM', 'iGATE');"
INSERT 0 1
[postgres@rac1 ~]$ psql -c "INSERT INTO emp VALUES ('RAJ', 'DBA', 'RCM', 'iGATE');"
INSERT 0 1
[postgres@rac1 ~]$
[postgres@rac1 ~]$ psql -c "SELECT * FROM EMP;"
name | designation | project | company
------+-------------+---------+---------
Sugi | DBA | Jetstar | iGATE
Teja | DBA | RCM | iGATE
RAJ | DBA | RCM | iGATE
(3 rows)
[postgres@rac1 ~]$
23.2 Standby 1 (rac2)
[postgres@rac2 ~]$ psql -c "SELECT * FROM EMP;"
name | designation | project | company
------+-------------+---------+---------
Sugi | DBA | Jetstar | iGATE
Teja | DBA | RCM | iGATE
RAJ | DBA | RCM | iGATE
(3 rows)
[postgres@rac2 ~]$
23.3 Standby 2 (rac3)
[postgres@rac3 ~]$ psql -c "SELECT * FROM EMP;"
name | designation | project | company
------+-------------+---------+---------
Sugi | DBA | Jetstar | iGATE
Teja | DBA | RCM | iGATE
RAJ | DBA | RCM | iGATE
(3 rows)
[postgres@rac3 ~]$
Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.
Thank you,
Rajasekhar Amudala
Email: br8dba@gmail.com
Linkedin: https://www.linkedin.com/in/rajasekhar-amudala/