Strategies for keeping two mySQL databases (in separate locations) in sync? [duplicate]

余生长醉 提交于 2019-12-22 08:53:20

问题


Possible Duplicate:
Which is the best way to bi-directionally synchronize dynamic data in real time using mysql

I need advice:

How do I keep 2 mySQL databases (same structure) synced up across 2 locations?

What am I doing:
I am creating an application for a business with two locations. They need to share/update information in a database BUT the proprietor wants it to be internal not external, as he is worried about being able to run in case of an internet outage.

My Strategy so far:
I've set up two servers (one in each location) Each running local Apache + MySQL. The webapp is NOT accessible over the internet, only locally. The mySQL is accessible over SSL via the internet (with a complex password).

The local webapp runs and interacts with local mySQL for reads. For writes, it writes locally then to the remote server (writing 2x).

I am concerned about creating duplicate/corrupted entries when record ids might be duplicated / different, etc... This is why I don't rely on record id, but rather on a separate unique number that I control (not auto-increment).

Bottom line... This is the best I could come up with after doing extensive research. Am I right? Or can someone offer advice?


回答1:


This is called replication, and MySQL (like any mature database management system) has native support for it. See: http://dev.mysql.com/doc/refman/5.0/en/replication.html




回答2:


You might be looking for distributed transactions. MySQL offers XA transaction support (see their documentation for more information).



来源:https://stackoverflow.com/questions/11541237/strategies-for-keeping-two-mysql-databases-in-separate-locations-in-sync

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!