INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / Thingiverse / RSS / GPG

Compare Postgresql tables by records count in tables

№ 11080 В разделе "Sysadmin" от July 16th, 2020,
В подшивках: ,

You have servers with master-slave(s) replication and want to be sure what all tables is synced. Program queries count of records for every table in database and shows to you on screen. Used on servers with logical replication and wal-g.

Create config.yaml with connection strings:

credentials:
  master: postgres://username:password@pg-master.server.ru:5433/mydatabase?sslmode=disable
  slave_logical: postgres://username:password@pg-slave1.server.ru:5432/mydatabase?sslmode=disable
  slave_walg: postgres://username:password@pg-slave2.server.ru:5435/mydatabase?sslmode=disable

Sample output, table ga is out of sync on slave_walg:

2020/07/16 05:45:45 master successfully connected!
2020/07/16 05:45:46 slave_logical successfully connected!
2020/07/16 05:45:46 slave_walg successfully connected!
2020/07/16 05:45:46 Table name: ga
2020/07/16 05:46:07 Postgres name: master Count: 25381158
2020/07/16 05:45:51 Postgres name: slave_logical Count: 25381158
2020/07/16 05:46:06 Postgres name: slave_walg Count: 25342939
2020/07/16 05:46:07 ------------

Source code and install https://git.blindage.org/21h/compare-postgres-tables

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Яндекс.Метрика

Fortune cookie: If your sexual fantasies were truly of interest to others, they would no longer be fantasies. -- Fran Lebowitz