Check server mode (standby / master)

Started by Alexander Perepelicaover 14 years ago3 messagesgeneral
Jump to latest
#1Alexander Perepelica
perepelica.alex@gmail.com

Hello!

How can I check which mode has a sever: master or slave (standby) after I
setup replication?

Thank you!
Alex

#2raghu ram
raghuchennuru@gmail.com
In reply to: Alexander Perepelica (#1)
Re: Check server mode (standby / master)

On Tue, Aug 16, 2011 at 1:16 PM, Alexander Perepelica <
perepelica.alex@gmail.com> wrote:

Hello!

How can I check which mode has a sever: master or slave (standby) after I
setup replication?

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]

--Raghu Ram

#3Simon Riggs
simon@2ndQuadrant.com
In reply to: Alexander Perepelica (#1)
Re: Check server mode (standby / master)

On Tue, Aug 16, 2011 at 8:46 AM, Alexander Perepelica
<perepelica.alex@gmail.com> wrote:

How can I check which mode has a sever: master or slave (standby) after I
setup replication?

You can run the query pg_is_in_recovery(), available since 9.0
http://developer.postgresql.org/pgdocs/postgres/functions-admin.html#FUNCTIONS-RECOVERY-INFO-TABLE

--
 Simon Riggs                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services