Re: Detecting master/slave - Mailing list pgsql-general

From Sameer Kumar
Subject Re: Detecting master/slave
Date
Msg-id CADp-Sm4rtM4SX8TJh-12_WRrx4iwCGasB0VkFin6G-aRLkd_pQ@mail.gmail.com
Whole thread Raw
In response to Detecting master/slave  (Steve Pribyl <Steve.Pribyl@akunacapital.com>)
List pgsql-general


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

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: Detecting master/slave
Next
From: "Nestor A. Diaz"
Date:
Subject: Re: pgsql_tmp consuming all inodes