Site icon Database Tutorials

PostgreSQL Streaming Replication

 

Master Server / Primary Server Set Up
1. Configuration Changes in file “postgresql.conf

 

2. Configuration Changes in file “pg_hba.conf” Make an entry for replication user with Slave server IP:

 

3. Restart the PostgreSQL service in Primary for changes to get impact:

 

Slave Server/ Secondary Server Set Up

1.Stop the PostgreSQL service in slave server if running.

 

2. Delete Or Rename the existing data directory.

 

3. Create new data directory.

 

4.Change owner of newly created data directory.

 

5. Give read, write, execute permission to only postgres user.

 

6. Execute pg_basebackup utility in slave server as postgres user.

 

7. After backup completion, create or edit “recovery.conf” file.

 

8. Start the PostgreSQL service in Slave server.

 

9. Check the Postgres log, It will show message as below:

database system is ready to accept read only connections.”

* To check the replication status, you can run below query in master to get the slave server details:

 

Exit mobile version