Dual master replication and risks
A dual master replication is very simple to implement. If you know how to build a slave, you'll be able to create a dual master easily. It's in fact a slave replication on both sides. The following diagram shows dual-sided replication:
This means that in theory you can write to both MariaDB instances at the same time. However, doing so is likely to result in inconsistent data between the two hosts, breaking replication (because of PRIMARY
/UNIQUE
key collisions) and, worse than that, you may end up having inconsistent data between two hosts.
Tip
Do not write on to both the masters at the same time!
The preceding tip mentions a rule that you need to follow to avoid issues in the production usages. You can minimize this kind of issue by adding the following two options in your MariaDB configuration file:
auto-increment-increment=2 auto-increment-offset=1
- This will avoid primary key collisions on the same rows of the same table:
auto-increment-increment...