1. Open the file using the command:
    vi /etc/repmgr/10/repmgr.conf
  2. In the file, make the following changes: Remove the # signs before the configuration headers for them to become active.
    Configuration Description
    node_id = 1 This needs to be a unique numeric identifier across the cluster greater than 0— for the primary, we have used 1.
    node_name = ‘N1’ This needs to be a unique (text and/or numerals) identifier across the cluster— for the primary, we have used N1.
    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 the 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 primary 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 service.
    service_stop_command = ‘sudo systemctl stop postgresql-10’ The stop command for PostgreSQL service.
    service_restart_command = ‘sudo systemctl restart postgresql-10’ The restart command for PostgreSQL service.
    service_reload_command = ‘sudo systemctl reload postgresql-10’ The reload command for PostgreSQL service.

    If you do not need your password 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

  3. After changing the above configurations, initialize the primary node. This should be done by the Linux user postgres using the following commands:
    su - postgres


    /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf master register

    exit
  4. Once this is completed, reboot the server using the command:
    sudo reboot
  5. Make sure that the primary node was registered by running the following commands:
    su - postgres
    /usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf cluster show

Once this is completed, you will need to configure REPMGR on the secondary (replica) node.