Thread: Detecting master/slave

Detecting master/slave

From
Steve Pribyl
Date:
Is there a better/recommended way to determine which host in a cluster is the master or slave besides rescue.conf or
pg_stat_replication? Just looking for the "right" way to know which host is which. 

Thanks

Steve
________________________________
 [http://www.akunacapital.com/images/akuna.png]
Steve Pribyl | Senior Systems Engineer
Akuna Capital LLC
36 S Wabash, Suite 310 Chicago IL 60603 USA | www.akunacapital.com <http://www.akunacapital.com>
p: +1 312 994 4646 | m: 847-343-2349 | f: +1 312 750 1667 | Steve.Pribyl@akunacapital.com

Please consider the environment, before printing this email.

This electronic message contains information from Akuna Capital LLC that may be confidential, legally privileged or
otherwiseprotected from disclosure. This information is intended for the use of the addressee only and is not offered
asinvestment advice to be relied upon for personal or professional use. Additionally, all electronic messages are
recordedand stored in compliance pursuant to applicable SEC rules. If you are not the intended recipient, you are
herebynotified that any disclosure, copying, distribution, printing or any other use of, or any action in reliance on,
thecontents of this electronic message is strictly prohibited. If you have received this communication in error, please
notifyus by telephone at (312)994-4640 and destroy the original message. 


Re: Detecting master/slave

From
Nitesh Gupta
Date:

Hey steve ,

You can by using grep command
Ps -ewf | grep PostgreSQL

If you find sender process is running that will be master if you will see receiver process then that will be slave
In addition to this you can also use Edb fail over manager for more status

Re: Detecting master/slave

From
Thomas Kellerer
Date:
Steve Pribyl schrieb am 21.11.2014 um 15:13:
> Is there a better/recommended way to determine which host in a
> cluster is the master or slave besides rescue.conf or
> pg_stat_replication?
>
> Just looking for the "right" way to know which
> host is which.

What about

  select pg_is_in_recovery()

should return true on the slave and false on the master.


Re: Detecting master/slave

From
Sameer Kumar
Date:


On 21 Nov 2014 22:14, "Steve Pribyl" <Steve.Pribyl@akunacapital.com> wrote:
>
> Is there a better/recommended way to determine which host in a cluster is the master or slave besides rescue.conf or pg_stat_replication?  Just looking for the "right" way to know which host is which.
>

You may query

select pg_is_in_recovery();

This will be true in hosts which are currently in recovery mode i.e. standby. It will be false for master.

As suggested previously you may check the wal sender process too but if you have a cascaded setup you may find these processes on a standby which is replicating to a cascaded standby.

> Thanks
>
> Steve
> ________________________________
>  [http://www.akunacapital.com/images/akuna.png]
> Steve Pribyl | Senior Systems Engineer
> Akuna Capital LLC
> 36 S Wabash, Suite 310 Chicago IL 60603 USA | www.akunacapital.com <http://www.akunacapital.com>
> p: +1 312 994 4646 | m: 847-343-2349 | f: +1 312 750 1667 | Steve.Pribyl@akunacapital.com
>
> Please consider the environment, before printing this email.
>
> This electronic message contains information from Akuna Capital LLC that may be confidential, legally privileged or otherwise protected from disclosure. This information is intended for the use of the addressee only and is not offered as investment advice to be relied upon for personal or professional use. Additionally, all electronic messages are recorded and stored in compliance pursuant to applicable SEC rules. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, printing or any other use of, or any action in reliance on, the contents of this electronic message is strictly prohibited. If you have received this communication in error, please notify us by telephone at (312)994-4640 and destroy the original message.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general