PostgreSQL Replication. Check status.

PostgreSQL Replication. Check status.

Colleagues hello to all.

In today's article, we'll talk about how to check replication statuses in PostgreSQL. On the origin server, the walsender process is responsible for replication, and on the replica server, the walreceiver process is responsible.

Previous articles:

  1. Download and install Postgresql 14 on Linux CentOS/RHEL 8/7 TAR
  2. PostgreSQL 14 simple replication setup

 

Article content:

  1. Check by process.
  2. Check with SQL query.

 

1. Checking by processes.

The first way to check replication is that we can check which processes are running in the database.

$. ps aux | grep postgres

 

Primary - Source

postgresql_status_replication

In this screenshot, we can see the walsender process, and it indicates that the server 192.168.2.232 is currently connected to it. This process also tells us that replication is streaming.

 

Standby - Replica

postgresql_status_replication

In this screenshot, we can see the walreceiver and startup recovering process. These two processes are responsible for replication.


 

2. SQL query validation.

You can also check the replication status by running a query on the source server.

sql> select * from pg_stat_replication;

postgresql_status_replication

The result of the query shows us that a replica is currently connected to the source server. The most important thing is that the values ​​of the sent_lsn, write_lsn, flush_lsn, replay_lsn parameters are the same.


 

Thank you all, I hope that my article helped you in some way.

SIMILAR ARTICLES

PostgreSQL - How to determine which files on disk correspond to tables in a database
PostgreSQL - How to determine which files on disk correspond to tables in a database
POSTGRESQL
Read more
PostgreSQL - How to find out the size of tables in a database
PostgreSQL - How to find out the size of tables in a database
POSTGRESQL
Read more
PostgreSQL - How to check user privileges
PostgreSQL - How to check user privileges
POSTGRESQL
Read more