0

I've a great dilema here and didn't know how to solve it. I need to replicate a few tables from MySQL DB (slaves) to MySQL DB (master). Take as an example this:

MySQL DB (master)
 table1
 table2
 table3

MySQL DB (slave1)
 table1
 table2
 table3

MySQL DB (slave2)
 table1
 table2
 table3

MySQL DB (master) should replicate content of table1 all days to MySQL DB (slave1, slave2) and MySQL DB (slave1, slave2) should replicate content of table2 and table3 to MySQL DB (master) all days. Tables are identical but data can change between master and slaves. I have a few questions around this:

  1. Does any know a solution for this? I mean how I can implement this?
  2. MySQL hosts are not in the same network so how to deal with this side?
  3. Because tables has the same structure what happens if for example ID column have the same values in master table1 and slave table1? Will be overwritten? Will be added as a new record?
  4. How to maintain integrity?
  5. What happens if slaves modify a record that has previously synchronized with master?

MySQL hosts are mostly Windows 7 PC

ReynierPM
  • 700
  • 5
  • 14
  • 28

1 Answers1

0

MySQL replication is not meant to work like that. If you allow writes on replication slaves, then your database will most propably become inconsistent over time. Sure, multi-master replication is possible, but you/your software has to be super careful not do anything that could possibly lead to future inconsistencies.

I'd recomment not do do this. Either stick with one master that gets all querys which alter data and send reading queries to one of the slaves, or set up a MySQL Cluster.

Henry S.
  • 141
  • 4