Multi-Master Replication for PostgreSQL databases with Postgres-BDR
One of the most challenging thing when scaling your backend to a new server cluster in a new region is replicating the databases. Most of the time, master-slave replication is not enough and you need to find a solution for master-master replication which can do the replicating job smoothly in realtime. And today we will learn how to setup a multi-master replication for PostgreSQL database with Postgres-BDR.
Bi-Directional Replication for PostgreSQL (Postgres-BDR, or BDR) is the first open source multi-master replication system for PostgreSQL to reach full production status.
0. What if I already have a running PostgreSQL database system?
That is a bad news but don’t worry, we can deal with it. In this case we need to dump all the data and restore it to the new PostgreSQL server with Postgres-BDR plugin. For dumping the database, you can take a look at: https://www.postgresql.org/docs/9.4/static/backup-dump.html
If your database is small, this process may be really fast, but if your database is really big, be carefully and choose a good time for doing this to prevent downtime to your application.