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:
- Download and install Postgresql 14 on Linux CentOS/RHEL 8/7 TAR
- PostgreSQL 14 simple replication setup
Article content:
- Check by process.
- 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
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
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;
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.