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();
(1 row)
If Return  false so the server is running in primary mode or master
postgres=# select pg_is_in_recovery();
(1 row)


Popular posts from this blog

PostgreSQL pgBadger

PostgreSQL Pgbadger Installation On Linux

How to configure Replication Manager (repmgr) ?

What's is the difference between streaming replication Vs hot standby vs warm standby ?

Script to kill ALL IDLE Connection In postgreSQL