From: | Alberto Olivares <alberto(dot)olivares(at)snowflakesoftware(dot)com> |
---|---|
To: | Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com> |
Cc: | "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: SQL command in Slave Database - Monitor Replication |
Date: | 2015-07-06 08:35:22 |
Message-ID: | CAGdoAzh7+dLNBZMrtL6f2rvmCFSd3Ax_SKmT5m3Oz3GJX4w+Fw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi Matheus,
Thanks for your answer. I do not have access to the primary database. So,
I cannot run a SQL in there.
I need to run the command in the Slave database that tells me whether the
replication is still working or not.
Regards,
Alberto.
*Alberto Olivares Colas*Technical Consultant
Snowflake Software
Tel.: +44 (0)2380 386578
Email: alberto(dot)olivares(at)snowflakesoftware(dot)com
Website: www.snowflakesoftware.com
Twitter: @sflakesoftware <http://www,twitter(dot)com(at)sflakesoftware/>
Follow us on LinkedIn <http://www.linkedin.com/company/snowflake-software>
*Winner of IHS Jane's ATC Award - Enabling Technology*
*Read more <http://www.snowflakesoftware.com/2015/03/janes-award/>*
Registered in England & Wales. Registered Number: 4294244
-----------------------------------------------------------------------------------------
On 4 July 2015 at 15:37, Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
wrote:
>
> On Fri, Jul 3, 2015 at 12:03 PM, Alberto Olivares <
> alberto(dot)olivares(at)snowflakesoftware(dot)com> wrote:
>
>> Is there any SQL command that I can run on the slave database to check if
>> the replication is still working or not? I know that you can check the
>> postgresql.conf but I want to do it directly on the SQL panel.
>>
>> Database: Postgresql 9.1 on Linux
>>
>
> You can query pg_stat_replication (since 9.1+) on the primary server, it
> will return one row for each secondary connected.
>
> If you were on 9.2+ you could even use pg_xlog_location_diff to get the
> lag in bytes of data sent to the standby:
>
> SELECT
> application_name,
> client_addr,
> pg_size_pretty(pg_xlog_location_diff(pg_current_xlog_location(),
> sent_location)) AS sent_lag
> FROM pg_stat_replication;
>
> You can use write_location and replay_location similarly.
>
> On 9.1 you'll have to do this math by yourself if you want or create your
> own pg_xlog_location_diff.
>
> OBS: pg_stat_replication will only show standby connected through
> streaming replication, log shipping cannot be verified this way.
>
> Best regards,
> --
> Matheus de Oliveira
>
>
--
*Winner of IHS Jane's ATC Award - Enabling Technology*
*Read more <http://www.snowflakesoftware.com/2015/03/janes-award/>*
From | Date | Subject | |
---|---|---|---|
Next Message | David Osborne | 2015-07-06 09:00:40 | Re: Running two postgresql servers in same Ubuntu machine |
Previous Message | AL-Temimi, Muthana | 2015-07-06 07:50:48 | Cached Memory increasing up and drop the caches through sync; echo 1 > /proc/sys/vm/drop_caches |