Re: Detecting master/slave

From: Sameer Kumar <sameer(dot)kumar(at)ashnik(dot)com>
To: Steve Pribyl <Steve(dot)Pribyl(at)akunacapital(dot)com>
Cc: PostgreSQL General Discussion Forum <pgsql-general(at)postgresql(dot)org>
Subject: Re: Detecting master/slave
Date: 2014-11-21 14:39:40
Message-ID: CADp-Sm4rtM4SX8TJh-12_WRrx4iwCGasB0VkFin6G-aRLkd_pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21 Nov 2014 22:14, "Steve Pribyl" <Steve(dot)Pribyl(at)akunacapital(dot)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(dot)Pribyl(at)akunacapital(dot)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(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Nestor A. Diaz 2014-11-21 14:54:43 Re: pgsql_tmp consuming all inodes
Previous Message Thomas Kellerer 2014-11-21 14:19:59 Re: Detecting master/slave