You need to configure the REPMGR configuration file on the replica node.

  1. Open the file using the command:
    vi /etc/repmgr/10/repmgr.conf
  1. In the file make the following changes. Remove # signs before the configuration headers for them to become active.
Configuration Description
node_id = 2 This needs to be a unique numeric identifier across the cluster greater than 0– for the secondary we have used 2.
node_name = ‘N2’ This needs to be a unique string (text and/or numerals) identifier across the cluster– for the secondary we have used N2.
conninfo = ‘host=LOCALIP port=5432 user=repuser dbname=postgres password={repuser_user_Password_Here}’ Replace LOCALIP with the server IP. This provides the connection info to this node to all replicas across the replication cluster. This determines the data directory– used for command line usage (such as pg_ctl etc.).
data_directory = ‘/var/lib/pgsql/10/data’ Tells REPMGR where the data directory is located at.
replication_type = ‘physical’ IN latest REPMGR there is a possibility of a bug, so leave this with # as it is. Determines that streaming replication will be used.
use_replication_slots = yes Makes REPMGR create and use replication slots– allows the failed over node to rejoin as secondary and have the delta.
pg_bindir = ‘/usr/pgsql-10/bin’ Required for running command line tools from PostgreSQL’s binary folder.
failover = ‘automatic’ Determines if the failover should be automatic or manual.
promote_command = ‘/usr/pgsql-10/bin/repmgr standby promote -f /etc/repmgr/10/repmgr.conf —log-to-file’ Determines the action taken when this node should become a primary.
follow_command = ‘/usr/pgsql-10/bin/repmgr standby follow -f /etc/repmgr/10/repmgr.conf —log-to-file —upstream-node-id=%n’ Determines the action taken when this node should become a replica and follow the new primary.
monitoring_history = yes Logs information about the activity in the replication cluster.
monitor_interval_secs = 10 The interval for monitoring logins.
service_start_command = ‘sudo systemctl start postgresql-10’ The start command for PostgreSQL’s service.
service_stop_command = ‘sudo systemctl start postgresql-10’ The stop command for PostgreSQL’s service.
service_restart_command = ‘sudo systemctl restart postgresql-10’ The restart command for PostgreSQL’s service.
service_reload_command = ‘sudo systemctl reload postgresql-10’ The reload command for PostgreSQL’s service.

After changing the above configurations, you need to initialize the replica node. Before initializing this node, you must delete its data and clone the data from the primary node.

If the password does not need to be in plaintext in a world-readable file, you can deduct other permission bits from it and add postgres rights to read:
chmod 0600 /etc/repmgr/10/repmgr.conf
setfacl -m u:postgres:rx /etc/repmgr/10/repmgr.conf

  1. Shut down postgreSQL-10 using the command:
    systemctl stop postgresql-10
  1. Delete the replica data using the following commands:
    cd /var/lib/pgsql/10/data
    rm -rdf *
  1. Next, clone the data from the primary node using the following commands:
    su postgres
    PGPASSWORD={repuser_user_Password_here} /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf -h {PRIMARY_DB_IP} -U repuser -d postgres standby clone
    exit
  2. Start the PostgreSQL as root user using the command:
    systemctl start postgresql-10
  3. Register the standby server using the following commands:
    su postgres
    /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf standby register --force


  1. Next, make sure that the primary node was successfully registered by running the following commands:
    /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf cluster show
    exit

  1. You can start REPMGR for both primary and replica nodes while logged in as root user using the command:
    systemctl enable --now repmgr10

Need more help with this?
Click here to open a Support ticket

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.