开发者

Mysql Replication Question

开发者 https://www.devze.com 2023-02-18 20:05 出处:网络
currently I have this scenario, multiple desktop client with mysql db installed on their windows machine.

currently I have this scenario,

  1. multiple desktop client with mysql db installed on their windows machine.
  2. need to sync over to one server hosted on web for reporting purpose.
  3. just need to do one way sync ( client to web ).
  4. client ip is always changing since they use standard adsl with no fix ip.
  5. each client db will sync to one stand alone db on s开发者_如何学Cerver ( hosted on web).
  6. can this syncing run on scheduler ? like every 3 hour since once.

I m thinking of using mysql replication, but I have some of the question on how to setup this? shall I setup this as master to slave ? or master to master ? I assume that the client will be master and the server will be slave , since the server is only use for reporting purpose, but checking on lots of mysql replication , it seem like the replication is initial from slave ? ( i see there are setting like master-host=ip on slave server setting ) this defeat the purpose since the server not sure about the client ip...


Perhaps this is totally off the mark given some of the items you're mentioning (slave/master/etc), but in an app I am developing, I have a similar architecture with the single source feeding multiple clients of unknown/dynamic IP. My solution was to include another field with a timestamp of when that row was last updated, then to sync, the clients search their local db for the MAX in that column, and send that as a variable to a webservice that then returns all rows with a more recent timestamp. The client then parses through the response data, and REPLACES INTO their local db, so that old data is over-written.

One detail I did not address (as my scenario does not need it) is how to communicate that an item has been deleted...perhaps when a row is deleted, an entry is made in another table with the row primary id, and timestamp of deletion, and then the web service could include an array of all rows with a more recent timestamp of that table.

0

精彩评论

暂无评论...
验证码 换一张
取 消