How far apart (ping time) are the two cities? 80ms is what we experience going across the US. It is not bad.
Writing to both heads of Master-Master is possible, but has lots of pain points.
NDB Cluster allows hot-hot, but (as you say) requires some conversion.
So, back to what I see as the only viable solution: A single writable master, plus any number of slaves.
One thing that can make a remote master painful is if the user's "unit" of action translates into many SQL statements. That can/should be solved by
(1) Rethink the code to use fewer statements
(2) Use a Stored Procedure to encapsulate as many of the SQL statements as possible, then deploy that on the remote Master.
Reads (other than "critical reads") can/should go to a slave, behind a load balancer. And some mechanism should ensure that reads are usually "local".
Using replicate-wild-do-table
=% is not the correct way to get complete replication. That would seem sensible, but here's why it isn't:
The replicate-*
options are restrictive by their presence. The *-do-*
options seem to be telling the server what to "do," but in fact they are telling the server what to only do.
The complete absence of any replicate-*
configuration variables means "replicate everything."
In the simplest case, when there are no --replicate-*
options, the slave executes all statements that it receives from the master. Otherwise, the result depends on the particular options given. -- http://dev.mysql.com/doc/refman/5.5/en/replication-rules.html
That, I think, is the point you are needing. It holds true for all MySQL 5.x.
Once you enable binary logging, set the server-id values on each machine, synchronize the data sets, CHANGE MASTER TO ...
, and then START SLAVE
, then you should have a working configuration where all DML and DDL will be replicated and your servers will be identical replicas of each other.
If you started out with identical data sets, everything should behave exactly as you would expect it to.
What MySQL replication does best and simplest is replicate entire data sets among servers without any restrictions. Trying to restrict replication to a subset of the data is a process that should carry a warning label that ends with the phrase "...unless you really know what you're doing."
When you use the --replicate-*
options, the document cited above also offers this tip:
it is recommended that you avoid mixing “do” and “ignore” options, or wildcard and nonwildcard options
You are using a mix of these, which adds complexity and may explain why your DDL didn't replicate as you expected it to.
Best Answer
You cannot use AND. The construction
WHERE (FLIGHTS.destination_city = 'Honolulu') and (FLIGHTS.destination_city = 'Newark')
which you tries to use means that you want to find a record in which destination is both Honolulu and Newark IN THE SAME RECORD. Of course, it is impossible.If the destinations count is strongly 2, the danblack's solution seems to be optimal.
If the destinations count vary, you must use some another method.
For MySQL it is: select records, where destination is Honolulu OR Newark OR another city which you need, then count the number of unique destination cities in the filtered records for each separate source city, and select only records where this count is equal to the number of destination cities:
fiddle