Steps :
ON MASTER SERVER :
1) check parameters in postgresql.conf file
--listen_addresses = '*'
--wal_level='replica'
--hot_standby='on'
2) Create replication user
--create user repuser with replication encrypted password 'abc';
--\du --> to check user created or not?
3) Modify pg_hba.conf file as per below entry
#host replication repuser 192.168.0.0/24 md5
4) Restart/Reload postgres config/services
ON SLAVE SERVER :
1) Stop Postgresql database
2) Delete all files under data directory (/var/lib/pgsql/12/data)
3) Run pg_basebackup to clone the standby instance. (Linux Command)
$ pg_basebackup -h 192.168.0.105 -U repuser -p 5432 -D /var/lib/pgsql/12/data/ -Fp
-Xs -P -R -C -S pgstandby
4) check standby.signal and postgresql.auto.conf file is generated
5) Start the standby database
Monitoring
1) To check whether standby DB is recovery or not?--run on standby server
--selct pg_is_in_recovery();
2)
select * from pg_stat_replication;
Failover
pg_ctl promote -D /var/lib/pgsql/12/data