Thread: How to find out if the server is postgres slave ??

How to find out if the server is postgres slave ??

From
expertalert
Date:
From command line, is there any way to find out if the server is actually a
slave server not master ??

I am writing some script, so for sanity check purpose   , i need to know if
the server the server i am on , its actually slave

thanks for your help.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/How-to-find-out-if-the-server-is-postgres-slave-tp5730418.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: How to find out if the server is postgres slave ??

From
dinesh kumar
Date:
Hi ,

We can use pg_is_in_recovery() command to check whether the server is in recovery or not. 

I believe, we can get this information from pg_controldata's "database cluster state" as well. 

Best Regards,
Dinesh
manojadinesh.blogspot.com

On Fri, Nov 2, 2012 at 3:36 AM, expertalert <expertalert@gmail.com> wrote:

From command line, is there any way to find out if the server is actually a
slave server not master ??

I am writing some script, so for sanity check purpose   , i need to know if
the server the server i am on , its actually slave

thanks for your help.





--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-to-find-out-if-the-server-is-postgres-slave-tp5730418.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: How to find out if the server is postgres slave ??

From
Chris Angelico
Date:
On Fri, Nov 2, 2012 at 9:06 AM, expertalert <expertalert@gmail.com> wrote:
>
> From command line, is there any way to find out if the server is actually a
> slave server not master ??
>
> I am writing some script, so for sanity check purpose   , i need to know if
> the server the server i am on , its actually slave
>
> thanks for your help.

select pg_is_in_recovery()

If it's true, you're on a slave; if false, master.

ChrisA