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

Oracle DBMS SCHEDULER Examples

7 Steps to configure BDR replication in postgresql

How to Get Table Size, Database Size, Indexes Size, schema Size, Tablespace Size, column Size in PostgreSQL Database

vacuumlo - removing large objects orphans from a database PostgreSQL