How to Rebuild the standalone postgres slave server ?
If slave Connection is Broken form master due to network issue or some some data mismatch so we have to rebuild the slave server by following below six steps .
TO REBUILD THE STANDBY SERVER BY FOLLOWING THE SIMPLE 6 STEPS :
- Current Master : 10.100.128.82
- Current Slave Server : 10.100.128.81 ( Slave Connection is broken from master )
1. Stop the slave server:
/opt/edb/as9.6/bin/pg_ctl -D /opt/edb/as9.6/data stop
2. Create recovery.conf file if not exist on slave server then update the the new master information in primary_connection field
Make sure your recovery.conf matches your environment
standby_mode = 'on'
primary_conninfo='host=10.100.128.82 port=5444 user=replica password=tcs@12345 application_name=pgslave001'
restore_command = 'cp /opt/edb/as9.6/data/archive/%f "%p"'
trigger_file = '/tmp/postgresql.trigger.5444'
3. Take the incremental backup From new postgres master Server:
/opt/edb/as9.6/bin/psql -d edb -c "select pg_start_backup('initial_backup');"
rsync -cva --inplace --exclude recovery.conf --exclude recovery.done --exclude pg_hba.conf --exclude postgresql.conf /opt/edb/as9.6/data/ enterprisedb@10.100.128.81:/opt/edb/as9.6/data/
/opt/edb/as9.6/bin/psql -d edb -c "select pg_stop_backup();"
4. restarting new slave server:
[root@2ndquadrant.in-1]# /opt/edb/as9.6/bin/pg_ctl -D /opt/edb/as9.6/data start
MASTER:
[root@2ndquadrant.in-1]# ps -ef|grep receiver
enterpr+ 31404 25252 0 12:41 ? 00:00:00 postgres: wal sender process replica 10.11.128.81[36570] streaming 0/26000220
root 31840 31656 0 12:54 pts/0 00:00:00 grep --color=auto sender
SLAVE :
[root@2ndquadrant.in-2]# ps -ef|grep receiver
enterpr+ 23187 23180 0 12:41 ? 00:00:00 postgres: wal receiver process streaming 0/26000220
root 24411 23650 0 12:53 pts/0 00:00:00 grep --color=auto receiver
Now master and slave streaming connectivity is happened successfully . For IT Support or want to talk regarding for project please touch with US itsupport@rayafeel.com.