repmgr

Replication manager for PostgreSQL

Overview

PackageVersionCategoryLicenseLanguage
repmgr5.5.0ETLGPL-3.0C
IDExtensionBinLibLoadCreateTrustRelocSchema
9710repmgrNoYesNoYesNoNo-
Relatedpglogical pg_failover_slots pgactive bgw_replstatus postgres_fdw pglogical_origin pglogical_ticker dblink

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG5.5.01817161514repmgr-
RPMPGDG5.5.01817161514repmgr_$v-
DEBPGDG5.5.01817161514postgresql-$v-repmgr-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64

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

repmgr: Replication manager for PostgreSQL

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 node
  • repmgr standby clone - clone a standby from primary
  • repmgr standby register - register a standby node
  • repmgr standby promote - promote standby to primary
  • repmgr standby follow - follow a new primary
  • repmgr standby switchover - planned switchover
  • repmgr cluster show - display cluster status
  • repmgr cluster event - show cluster events
  • repmgr node check - health check a node

Last Modified 2026-03-12: add pg extension catalog (95749bf)