This needs to be carried out on the secondary (replica) node. Note that the commands executed here are different in the secondary node.

  1. Configure the REPMGR configuration file (default located on “/etc/repmgr/10/repmgr.conf”) by changing the configuration as follows:
node_id = 2
node_name = ‘N2’
conninfo = 'host=<LOCALIP> port=5432 user=repuser dbname=postgres password=<POSTGRES USER PASSWORD>'
replication_type = 'physical'
use_replication_slots = yes
pg_bindir = '/usr/pgsql-10/bin'.
failover = 'automatic' 
data_directory = '/var/lib/pgsql/10/data'
promote_command = '/usr/pgsql-10/bin/repmgr standby promote -f /etc/repmgr/10/repmgr.conf --log-to-file'
follow_command = '/usr/pgsql-10/bin/repmgr standby follow -f /etc/repmgr/10/repmgr.conf --log-to-file --upstream-node-id=%n'
monitoring_history = yes
monitor_interval_secs = 10
service_start_command = 'sudo systemctl start postgresql-10'
service_stop_command = 'sudo systemctl start postgresql-10'
service_restart_command = 'sudo systemctl restart postgresql-10'
service_reload_command = 'sudo systemctl reload postgresql-10'

After changing the above configurations, we need to initialize the replica node. This should be done by the linux postgres user except for the systemctl commands:

  1. Shutdown PostgreSQL (root):
    systemctl stop postgresql-10
  2. Delete the data directory (as it will be cloned later on):
    cd /var/lib/pgsql/10/data
    rm -rdf ** # Clone the data from the primary (postgres user): ## su – postgres@
    1. PGPASSWORD=<place postgres user password???**> /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf -h <primary-ip> -U repuser -d postgres standby clone
    2. exit
  3. Start PostgreSQL (root):
    systemctl start postgresql-10
  4. Register the standby (postgres user):
    1. su - postgres
    2. /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf standby register
    3. exit
  5. Ensure that the primary was registered by running the following commands:
    1. su - postgres
    2. /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf cluster show
    3. exit

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.