Re: replication consistency checking - Mailing list pgsql-admin
From | Guillaume Lelarge |
---|---|
Subject | Re: replication consistency checking |
Date | |
Msg-id | CAECtzeVk7AZ+94+Ew9nwfAu3wu_or5bS48bZFshEgf3csDJ_DA@mail.gmail.com Whole thread Raw |
In response to | Re: replication consistency checking (hydra <hydrapolic@gmail.com>) |
Responses |
Re: replication consistency checking
|
List | pgsql-admin |
Thanks Greg, this looks nice.However my original question still remains. You know, every software has bugs, every bits and pieces can break, hardware can be misbehaving. Really, checking the data and counting the checksum is the only way to be sure.
On Thu, Jun 4, 2015 at 11:12 AM, Greg Clough <greg.clough@cwtdigital.co.uk> wrote:If you're using Streaming Replication, then the internal PostgreSQL code ensures consistency... but if you wanted to make sure that your standby is applying logs, then you can use something like:postgres@HOST2:~$ psql -c 'select pg_last_xlog_receive_location() "receive_location", pg_last_xlog_replay_location() "replay_location", pg_is_in_recovery() "recovery_status";'
receive_location | replay_location | recovery_status
------------------+-----------------+-----------------
7/68002388 | 7/68002388 | t
(1 row)
... or as suggested previously, use repmgr, which has a "repmgrd" daemon that keeps things monitored for you:postgres@HOST1:~$ psql repmgr repmgr -c 'select * from repmgr_test.repl_monitor;'
primary_node | standby_node | last_monitor_time | last_apply_time | last_wal_primary_location | last_wal_standby_location | replication_lag | apply_lag
--------------+--------------+-------------------------------+-------------------------------+---------------------------+---------------------------+-----------------+-----------
1 | 2 | 2015-06-04 09:09:37.920809+00 | 2015-06-04 09:09:37.712235+00 | 30/F85D7280 | 30/F85D7280 | 0 | 0
1 | 2 | 2015-06-04 09:09:40.45123+00 | 2015-06-04 09:09:38.251625+00 | 30/F85D73C0 | 30/F85D73C0 | 0 | 0
1 | 2 | 2015-06-04 09:09:42.966728+00 | 2015-06-04 09:09:40.75668+00 | 30/F85D74C0 | 30/F85D74C0 | 0 | 0
1 | 2 | 2015-06-04 09:09:45.480471+00 | 2015-06-04 09:09:43.273428+00 | 30/F85D75C0 | 30/F85D75C0 | 0 | 0
1 | 2 | 2015-06-04 09:09:47.997739+00 | 2015-06-04 09:09:45.785806+00 | 30/F85D76C0 | 30/F85D76C0 | 0 | 0
1 | 2 | 2015-06-04 09:09:50.515236+00 | 2015-06-04 09:09:48.303822+00 | 30/F85D77C0 | 30/F85D77C0 | 0 | 0
Greg Clough
Database Administrator | CWT Digital
t. 0845 456 0070 w. cwtdigital.com
Units A/B, Level 8 North, New England House,
New England Street, Brighton, East Sussex, BN1 4GHOn 4 June 2015 at 09:47, hydra <hydrapolic@gmail.com> wrote:On Thu, Jun 4, 2015 at 8:27 AM, Venkata Balaji N <nag1010@gmail.com> wrote:On Thu, Jun 4, 2015 at 2:49 PM, hydra <hydrapolic@gmail.com> wrote:After setting up streaming replication, is it possible to check whether the slave has the same data as the master?Yes. There are quite a few ways to check the sync status between master and standby. Which version of PostgreSQL are you using by the way ?Generally, you can easily build some scripts and schedule them in cron to check the status. You can use functions or catalog views to monitor the status, this depends on the version of PG you are using.You can also use tools like "repmgr" to monitor and manage replication. I am not 100% sure how good or efficient it is.Regards,Venkata Balaji NFujitsu AustraliaThanks for the answer, however I'm looking for a data consistency check.That means, you deploy your master standby replication, you're happily running it and after 3 months you decide to do a failover. How can one be sure the data are the same?I'm running PostgreSQL 9.4.
--
pgsql-admin by date: