This needs to be carried out on the secondary (replica) node. Note that the commands executed here are different in the secondary node.
- 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:
- Shutdown PostgreSQL (root):
systemctl stop postgresql-10
- 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@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
exit
- Start PostgreSQL (root):
systemctl start postgresql-10
- Register the standby (postgres user):
su - postgres
/usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf standby register
exit
- Ensure that the primary was registered by running the following commands:
su - postgres
/usr/pgsql-10/bin/repmgr -f /etc/repmgr/10/repmgr.conf cluster show
exit
Need more help with this?
Click here to open a Support ticket