Chained MySQL replication from Master->Master replicated pair
-
02-10-2020 - |
Question
This is a pictorial view of what I have:
Master 1<----->Master 2
| |
| |
V V
Slave 1 Slave 2
The masters are never written to at the same time, rather Master 2 is a standby server. Both Masters have log-slave-updates
turned on in my.cnf
.
If a table is created in a replicated DB on Master 1, it is present on Master 1, Master 2 and Slave 1. It is NOT present on Slave 2.
In the same way, if a table is created in a replicated DB on Master 2, it is present on Master 1, Master 2 and Slave 2. It is NOT present on Slave 1.
Why is this the case? Is it a limitation of MySQL in how it stops master/master replicated servers from creating replication loops if both have log-slave-updates turned on?
Is there a way this can work?
Solution
To answer my own question, the "fix" is to change binlog_format to STATEMENT
. It was previously MIXED
.
Not entirely sure of the reason behind this - MySQL should be intelligent when using MIXED mode about what is replicated as statement and what is replicated as row.
OTHER TIPS
Since you have binlog/replicate filtering, this is probably what happened:
USE non_replicated_db;
CREATE TABLE replicated_db.table_name ...;
The filtering works on the USE
, not on the db qualification in the statement.
(PS, you are using what is probably the best layout for standard replication: dual-master-single-writer, plus slaves hanging off both. If the Masters are in different physical locations, it is even better.)