Edit:
The original version of this answer was suggested by MongoDB; but with further reading, MongoDB is not so reliable with dodgy internet connections. CouchDB is designed for standalone documents that you need, although unfortunately it's harder to get a gong than MongoDB.
Original:
I would suggest not using MySQL, but deploy a repository of documents designed for replication, such as CouchDB - unless you go to the commercial MySQL Clustering Services.
Being a lover of the power of MySQL, it's hard for me to suggest you use something else, but in this case you really need to.
That's why -
Problems Using MySQL Replication
Why MySQL had good replication (and, most likely, what you should use if you are synchronizing a MySQL database as recommended by others), there are some things to keep in mind.
- A “unique key” collision will give you a massive headache; most likely reason for this is the Auto Incrementing identifiers, which are common in MySQL applications (do not use them for synchronization if this is a clear read + write → read-only relationship that is not in your case.)
- Primary keys must be generated by each server, but unique to all servers. Perhaps adding a combination of a server identifier and a unique identifier for this server (Server1_1, Server1_2, Server1_3, etc. Will not collide with Server2_1)
- MySQL only supports synchronization on the go, unless you look at their clustering solutions ( https://www.mysql.com/products/cluster/ ).
Manual problems with time stamping.
In another answer, it is recommended that you keep the "Updated on time" entries. While I did this approach, there are some big problems to be careful.
Manual problems with logging.
Journalling keeps a separate record of what has changed and when. "Database X, table Y, field Z was updated to A at time B" or "A new record was added to table A with this data [...]." This allows you much better control over what to update.
- If you look at the database synchronization methods, this is actually what happens in the background; in case of MySQL, it stores a binary update log
- you only share the magazine, not the original entry.
- When another server receives a log entry, if it has a much larger report of what happened before / after, and can play back updates and ensure that you get the correct data.
- problems arise when a log / database exits Sync (MySQL is actually a pain when this happens!). You need to have an “update” script ready for roll, which is located outside the journal, which will synchronize the database with the master.
- It's complicated. So that...
Decision. Using a repository of documents designed for replication, for example. Mongodb
With all this in mind, why not use a document repository that already does all this for you? CouchDB supports and processes all journaling and synchronization ( <a6> ).
There are others, but I believe that you will have fewer headaches and mistakes than with other solutions.