Linux – Best way to keep two or more databases in sync

linuxpowerdns

I have two PowerDNS servers and have configured the zone records to be natively stored in mariaDB. What would be the best way to sync these two databases?

Note :

I would like to scale this to use 5 servers later on. Currently the data would be added to DNS server 1 and would only be copied from DNS server 1 to DNS server 2. If I have more DNS servers, I would like it if DNS server 1 goes down, then content created on DNS server 2 would serve DNS server 3 and so on and when DNS 1 is up again it would sync with DNS server 2.

There is also one table which will not be synced: that is the table that PowerDNS uses to store the server IP address and so on.

My server can only access mariaDB locally so for a remote computer to access mariaDB it would have to ssh tunnel.

Best Answer

Since you are asking this on SF and not on database I will give you an answer that does not replicate the database.

You want to replicate a DNS.

The official mean for that is either a peer DNS or a secondary DNS that might get promoted to primary.

In any case your main DNS has to push changes towards the peer/secondary.

That is done with DNS protocol on layer 7. So no need to replicate databases.