同步MySql DB数据
首先,我是分布式数据库世界的新手,无论如何,场景是:
我在美国、瑞典和澳大利亚有三台服务器,相同的Web应用程序已使用mysql数据库(相同的结构)部署在所有服务器上。由于不同的用户正在使用这些应用程序,并且所有三个数据库都有不同的数据;从现在开始,每当任何一台服务器中的数据发生变化时,我们都需要自动同步数据库数据;告诉我什么是优化的解决方案。
或者 如果我们对所有Web服务器使用同一个数据库服务器,会降低应用程序的速度吗?
请建议从什么开始。
first of all I am new to the distributed DB world, anynhow scenario is:
I have three servers in US, Sweden and Australia, same web application has been deployed on all of them with mysql DB (same structure). as different users are using these application and all three DBs have different data; now from now we need to synchronize the DB data every time if any change happened into the data in any one of the server automatically; tell me what can be the optimized solution.
or
if we use one same DB server for all web servers, will it slow down the speed of application ?
please suggest something to start with.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这几乎正是复制的目的。
http://dev.mysql.com/doc/refman/5.0 /en/replication-howto.html
编辑:除非您使用网络加速器公司(Akamai 等),否则由于响应时间慢,我不建议使用单个服务器。
This is pretty much exactly what replication is for.
http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html
EDIT: Unless you are using a web accelerator company (Akamai, etc) I don't suggest using a single server due to slow response times.
如果您使用标准 MySQL 复制,您将面临几个问题:
MySQL 复制基本上是 master ->奴隶。因此,更新是在主服务器上完成的,然后将其复制到从服务器上。这可能非常有效,但这通常意味着您的两个位置的更新速度会很慢,但读取速度会是正常的。
推论 1 - 事务发生在主服务器上,因此如果您创建新记录并获取 LAST_INSERT_ID() 并将其插入到另一个表中,则所有读取和写入都需要转到 MySQL 主服务器,因为更改不会被更改。在事务完成之前在从属服务器上可见。
您的现有数据可以集成到一个数据集中吗?如果没有,那么您可能会遇到问题。
应用程序是否“支持办公室”。换句话说,如果你把几个办公室的数据放在一起,它还能工作吗?应用程序是否根据其所在的办公室对数据做出假设?
There are several issues you will face if you use standard MySQL replication:
MySQL replication is basically master -> slave. So updates are done on the master that then replicates tehm to the slave. This can be very effective, but it generally means that two of your locations will have slow updates, but reads will be normal speed.
A corrolary of 1 - Transactions take place on the Master so if you create anew record and get the LAST_INSERT_ID() and insert it into another table, all reads and writes need to go to the MySQL master as teh changes will not be visible on the slave until the transaction completes.
Can your existing data be integrated into one dataset? If not then you may have problems.
Is the application "office aware". In other words, if you put data from several offices together will it still work? Does the application make assumptions about the data based on the office it is in?