Can someone suggest the steps to check pgsql replication status and when to say replication is not happening properly?
We use streaming replication with pgsql9.0 and pgsql9.4
Thanks.
The only way to get the replica lag in seconds on a current PostgreSQL version is to have an external process commit an update to a dedicated timestamp table periodically.
You can use the replica_lag and network_lag metrics to monitor replication lag and identify whether the cause of the lag is in the primary database, the network, or the replica. The number of seconds that the replica's state is lagging behind the state of the primary instance.
What Is PostgreSQL Replication? The process of copying data from a PostgreSQL database server to another server is called PostgreSQL Replication. The source database server is usually called the Master server, whereas the database server receiving the copied data is called the Replica server.
I use following SQL queries to check status on Postgres v11 usually.
On master:
select * from pg_stat_replication;
On replica (streaming replication in my case):
select * from pg_stat_wal_receiver;
On your master, pg_stat_replication provides data about ongoing replication:
select client_addr, state, sent_location, write_location, flush_location, replay_location from pg_stat_replication;
On postgresql v10:
select client_addr, state, sent_lsn, write_lsn, flush_lsn, replay_lsn from pg_stat_replication;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With