repmgr
Replication manager for PostgreSQL
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
repmgr | 5.5.0 | ETL | GPL-3.0 | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 9710 | repmgr | No | Yes | No | Yes | No | No | - |
| Related | pglogical pg_failover_slots pgactive bgw_replstatus postgres_fdw pglogical_origin pglogical_ticker dblink |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 5.5.0 | 1817161514 | repmgr | - |
| RPM | PGDG | 5.5.0 | 1817161514 | repmgr_$v | - |
| DEB | PGDG | 5.5.0 | 1817161514 | postgresql-$v-repmgr | - |
Install
You can install repmgr directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install repmgr; # Install for current active PG version
pig ext install -y repmgr -v 18 # PG 18
pig ext install -y repmgr -v 17 # PG 17
pig ext install -y repmgr -v 16 # PG 16
pig ext install -y repmgr -v 15 # PG 15
pig ext install -y repmgr -v 14 # PG 14
dnf install -y repmgr_18 # PG 18
dnf install -y repmgr_17 # PG 17
dnf install -y repmgr_16 # PG 16
dnf install -y repmgr_15 # PG 15
dnf install -y repmgr_14 # PG 14
apt install -y postgresql-18-repmgr # PG 18
apt install -y postgresql-17-repmgr # PG 17
apt install -y postgresql-16-repmgr # PG 16
apt install -y postgresql-15-repmgr # PG 15
apt install -y postgresql-14-repmgr # PG 14
Create Extension:
CREATE EXTENSION repmgr;
Usage
A suite of tools to manage replication and failover within a PostgreSQL cluster. Supports setting up standby servers, monitoring replication, and performing failover/switchover.
Enabling
CREATE EXTENSION repmgr;
Configuration
Create repmgr.conf on each node:
node_id=1
node_name='node1'
conninfo='host=node1 dbname=repmgr user=repmgr'
data_directory='/var/lib/postgresql/data'
Register Primary
repmgr -f /etc/repmgr.conf primary register
Clone and Register Standby
# Clone from primary
repmgr -h primary-host -U repmgr -d repmgr -f /etc/repmgr.conf standby clone
# Start the standby
pg_ctl -D /var/lib/postgresql/data start
# Register the standby
repmgr -f /etc/repmgr.conf standby register
Monitoring
# Show cluster status
repmgr -f /etc/repmgr.conf cluster show
# Show replication status
repmgr -f /etc/repmgr.conf node status
Manual Switchover
Promote a standby to primary (planned switchover):
repmgr -f /etc/repmgr.conf standby switchover
Automatic Failover with repmgrd
Start the repmgr daemon on each node:
repmgrd -f /etc/repmgr.conf
Configure failover in repmgr.conf:
failover='automatic'
promote_command='repmgr standby promote -f /etc/repmgr.conf'
follow_command='repmgr standby follow -f /etc/repmgr.conf --upstream-node-id=%n'
Key Commands
repmgr primary register- register a primary noderepmgr standby clone- clone a standby from primaryrepmgr standby register- register a standby noderepmgr standby promote- promote standby to primaryrepmgr standby follow- follow a new primaryrepmgr standby switchover- planned switchoverrepmgr cluster show- display cluster statusrepmgr cluster event- show cluster eventsrepmgr node check- health check a node
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.