Re: How to check streaming replication status

From: Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>
To: Condor <condor(at)stz-bg(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-general-owner(at)postgresql(dot)org>
Subject: Re: How to check streaming replication status
Date: 2017-08-31 09:14:04
Message-ID: 2051823616.284568.1504170844513@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>From: Condor <condor(at)stz-bg(dot)com>
>To: Glyn Astill <glynastill(at)yahoo(dot)co(dot)uk>
>Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>; "pgsql-general-owner(at)postgresql(dot)org" <pgsql-general-owner(at)postgresql(dot)org>
>Sent: Thursday, 31 August 2017, 09:42:17 GMT+1
>Subject: Re: [GENERAL] How to check streaming replication status

>>> My question is: How I can check the replication status when the
>> slave
>>> does not accept connections ?
>>
>> That's right for a server in recovery you need to call
>> pg_last_xlog_receive_location() or pg_last_xlog_replay_location() to
>> get the current xlog position.
>
>
>Yes,
>but my question is how to call them when Im unable to connect with slave
>even when
>replication is over. How I can ask the slave server: Are you in recovery
>mode ?
>

Define "unable to connect", in your previous example you appeared to be connected to the slave and attempting to call pg_current_xlog_location() ...

If you want to know if postgres is in recovery call pg_is_in_recovery()

https://www.postgresql.org/docs/current/static/functions-admin.html

>
>What is the last wal file send from master, which file you processing
>now ?
>How far behind you ?
>
>As I ask:  My question is: How I can check the replication status when
>the slave does not accept connections ?

Again I think you need to define "the slave does not accept connections".

If you've not configured the slave to be a hot standby, then try setting hot_standby=on in postgresql.conf on the slave.  If you don't want to do that you can run the pg_controldata executable on the slave to see the cluster state.

You should also be able to see streaming replication slave lag on the master by looking at pg_stat_replication and using pg_xlog_location_diff()

hth

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Wagner 2017-08-31 09:50:41 ERROR: Undefined Reference to
Previous Message Condor 2017-08-31 08:41:50 Re: How to check streaming replication status