Mysql/Maridb failover in lxc containers

I’d like to make two Mysql master containers in lxc containers. Obviously they would need to fail over from each other as we need to do maintenance from time to time. Failing mysql between the containers is pretty trivial with pacemaker. The issue, as always, is the storage of data. On physical hosts DRDB is implemented, but that option doesn’t exist on containers. I have a glusterfs share that runs on all containers but it doesn’t seem that Mysql and glusterfs will play nicely together. Structured data and relational databases are specifically warned against.

I’ve also been recommended Galera, I’m just wondering about the experiences within the community.

I’ve been running Galera/mariadb for a year in production. It works very well!

I’m running it in lxd containers on 3 physical machines in different countries (Hetzner/OVH/Worldstream), over a private Wireguard LAN. My applications connect to mariadb as if it were a single host, I didn’t have to change much.

The only drawback is write latency: a transaction commit takes a roundtrip between the hosts. Read latency is not affected. Failover is completely automatic, I can reboot a host and everything keeps running.

This helped me get started (be sure to use mariadb 10.6 though):

1 Like

That sounds ideal, thanks. Write latency isn’t really a problem, within reason, as it will hold dns information that doesn’t change often.