pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <shammat@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Determine if postgresql cluster running is primary or not
Date: Fri, 20 Nov 2020 10:03:21 +0100
Message-ID: <f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net> (raw)
In-Reply-To: <CAO_+3-AV1WV_RfZ=7sbvNtwoZpvL23kpyzaUBJWRxhP47NVdOA@mail.gmail.com>
References: <CAO_+3-AV1WV_RfZ=7sbvNtwoZpvL23kpyzaUBJWRxhP47NVdOA@mail.gmail.com>

Raul Kaubi schrieb am 20.11.2020 um 09:53:
> CentOS 7
> Postgres 9 to 12
>
> For monitoring purpose, I would like that certain scripts are only run in primary server.
> So I am looking ways to universally discover if postgresql cluster that is running is primary or not.

As the standby will be in constant recovery, you can use

   select pg_is_in_recovery();






view thread (11+ messages)  latest in thread

Message-ID: <f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net>
Permalink:  ../f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net/
Also on:    postgresql.org/message-id/f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: shammat@gmx.net
  Subject: Re: Determine if postgresql cluster running is primary or not
  In-Reply-To: <f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net>
  References: <CAO_+3-AV1WV_RfZ=7sbvNtwoZpvL23kpyzaUBJWRxhP47NVdOA@mail.gmail.com> <f09b2f94-d9a5-473c-d726-7e1aa53a7e94@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox