0% found this document useful (0 votes)
0 views1 page

postgres_streaming_replication

The document outlines the steps for setting up PostgreSQL replication between a master and a slave server. It includes configuring the master server's parameters, creating a replication user, modifying the pg_hba.conf file, and performing a pg_basebackup on the slave server. Additionally, it provides commands for monitoring the replication status and promoting the standby database during failover.

Uploaded by

Ganesh Padwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views1 page

postgres_streaming_replication

The document outlines the steps for setting up PostgreSQL replication between a master and a slave server. It includes configuring the master server's parameters, creating a replication user, modifying the pg_hba.conf file, and performing a pg_basebackup on the slave server. Additionally, it provides commands for monitoring the replication status and promoting the standby database during failover.

Uploaded by

Ganesh Padwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

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

You might also like