Monitor PostgreSQL Replication

From Gejoreuy
Revision as of 14:40, 27 October 2020 by Gejor (talk | contribs) (Created page with "'''Find Out Which is Master or Slave''' # select pg_is_in_recovery() If it's true, we're on a slave; if false, master. '''List All Databases''' # \l '''Check Synchron...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Find Out Which is Master or Slave

# select pg_is_in_recovery()

If it's true, we're on a slave; if false, master.


List All Databases

# \l


Check Synchronization Status

postgres@dbmaster:~$ psql -x -c "select * from pg_stat_replication;"

This must be run in master db node. Or we can check the sync status only like below.

# select sync_state from pg_stat_replication;

Possible values of sync_state are:

async: This standby server is asynchronous -> CRITICAL!
potential: This standby server is asynchronous, but can potentially become synchronous if one of current synchronous ones fails -> WARNING
sync: This standby server is synchronous -> OK
quorum: This standby server is considered as a candidate for quorum standbys -> OK