~hacktivista/pglr

PostgreSQL logical replication
Replicate local changes only.
Fix: conditional -D flag on final output
Add dendrite_sync stored procedure

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~hacktivista/pglr
read/write
git@git.sr.ht:~hacktivista/pglr

You can also use your local clone with git send-email.

#PGLR: PostgreSQL Logical Replication

This software will guide you through a PostgreSQL logical replication setup that works for redundancy.

I built this because I needed a replication for communitary infraestructures (such as cheap SBCs, and home-networks with dynamic IPs) that could run over different architectures. It's intended to be solid enough as to behave correctly without any human intervention after initial setup in most cases, albeit there's no warranty implied.

#Requirements

  • POSIX-compilant operating system
  • sed that allows the -i flag (like GNU and BusyBox sed)
  • sudo
  • postgresql-dev or equivalent
  • libc-dev or equivalent
  • gcc
  • make
  • An already setup interconnection between Postgres hosts (ex: VPN for safe remote connection)

#Deploy

As root user.

On first-run

make
make install

Whenever you want to replicate a database

./setup.sh [options] <database>

Run it without a database parameter to see available options. -D is safe to use and will make setup faster.

#FAQ

#On which cases should I use this setup?

I use it for redundancy over different computer architectures, on almost every other case streaming replication is usually recommended. If you don't know which replication model to use, probably you want streaming replication, which is not what this is for.

#How can I explore the unique constraints available on the database?

With the psql command you can explore tables using \dt, check constraints of each table with \d+ <table>.

#Will I need something else for having redundancy?

Yes, for instance you could listen the primary server from the secondary one and update a DNS server record if it's down. Also running the pglr_seq_sync stored procedure might be a nice idea for data consistency. Here is an example of what I'm using.

#Will it work for multi-master?

Depending on your application and setup, it might.

#This is great, can I buy you a coffee?

Sure pal

#TODO

  • Probably use a .control PGXS file.

#License

GNU GPL v3 only.