Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

How to find the server is whether standby (slave) or primary(master) in Postgresql replication ?

Method 1
You can check the mode of the server using "pg_controldata".
[pgsql@test~]$ pg_controldata /usr/local/pgsql/data84/

Database cluster state:               in archive recovery   --> This is Standby  Database

Database cluster state:               in production  --> This is Production Database [Master]

Method 2
You can use pg_is_in_recovery() which returns True if recovery is still in progress(so the server is running in standby mode or slave)
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
t
(1 row)
If Return  false so the server is running in primary mode or master
postgres=# select pg_is_in_recovery();
pg_is_in_recovery
-------------------
f
(1 row)

Comments

Popular posts from this blog

VMWARE WORKSTATION 3,4,5,6,7,8,9,10,11,12,14,15...etc LICENSE KEYS COLLECTION

Oracle to Postgresql migration

PostgreSQL Enterprise Manager - PEM Monitoring Tools

7 Steps to configure BDR replication in postgresql