As I know starting from MySQL v5.7.6
the multi-source
replication is possible. So If we can have a slave that can get data from multiple masters. Can we have mesh replication, where each node act as a slave for all other nodes ?
Mesh Replication
If we have 4 nodes (N1, N2, N3, N4)
- N1 is a slave for N2, N3, N4.
- N2 is a slave for N1, N3, N4.
- N3 is a slave for N1, N2, N4.
- N4 is a slave for N1, N2, N3.
If yes we can do that ? How nodes detect duplicated events in such scenario:
- A new change in N1 is happened.
- N1 pushes this change into N2, N3, N4.
- The new change is received at N2 (and the other nodes).
- How N2 does't replicate it again ! Otherwise we will have a infinite loop !
Best Answer
It's called Galera.
A write to any node is automatically replicated to all other nodes.
Galera is usually deployed in 3-node configuration, but 4 is possible.
It is available from Percona (PXC), MariaDB, or an addon to MySQL.
Please explain why you want that configuration.
And, no, Galera won't get into an infinite loop. Nor will any other multi-master setup -- as long as you set
server-id
to different values on each Master.