Re: How to test replication without doing a failover - Mailing list pgsql-admin

From Holger Jakobs
Subject Re: How to test replication without doing a failover
Date
Msg-id 51397c23-b806-eb24-3bd0-986ef9c593c9@jakobs.com
Whole thread Raw
In response to How to test replication without doing a failover  (Edwin UY <edwin.uy@gmail.com>)
List pgsql-admin
Am 10.11.22 um 15:59 schrieb Edwin UY:
List

Very newbie here on PostgreSQL coming from an Oracle DBA background mostly

How do I test and confirm whether replication is working or not besides depending on just running the SQL below?

select pg_is_in_recovery() ;

select * from pg_stat_replication ;


Is it possible to force/initiate a log transaction and see if that gets replicated or not? I mean for example on Oracle we can do a switch logfile and check if that log gets shipped across and applied on the standby, is there something similar in PostgreSQL?
Maybe someone can refer me to an example if there is one somewhere?

Regards,
Ed


Monitoring the replication

Compare the WAL positions of primary and secondary: select pg_current_wal_lsn(); on the primary
select pg_last_wal_receive_lsn(); on the standby or in the ps output of WAL receiver process.

Using the view pg_stat_replication

Check the difference between pg_current_wal_lsn() and the column sent_lsn of the view shows high load of the primary.
Difference between the column sent_lsn of the view and pg_last_wal_receive_lsn() on the standby shows network congestion or that the standby has high load.




-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
Attachment

pgsql-admin by date:

Previous
From: Paul Smith
Date:
Subject: Re: How to test replication without doing a failover
Next
From: Rafał Kędziorski
Date:
Subject: Ubuntu 20.04: Problem with postgresql-client-common and postgresql-common upgrade