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 Database startup / shutdown /restart

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

2017 Shortern URL - Other Website Like ADFOC.US

ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated ORA-01262: Stat failed on a file destination directory Linux-x86_64 Error: 2: No such file or directory

PostgreSQL Pgbadger Installation On Linux