在线/离线数据库同步 - MySQL/PHP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7722659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 03:14:34  来源:igfitidea点击:

Online/Offline Database Synchronization - MySQL/PHP

phpmysqlsynchronization

提问by iamsumesh

I am developing a web application using php and mysql. This application runs on three different locations.

我正在使用 php 和 mysql 开发一个 web 应用程序。此应用程序在三个不同的位置运行。

  1. On internet
  2. Head office
  3. Branch office
  1. 在互联网上
  2. 总公司
  3. 分支机构

Application runs on local server on head office and branch office. Internet connection is not available on every time. Customers placing orders through these three locations. My problem is, I want to synchronize the data among these three databases and keep these three databases up to date. Is there any way to do this?

应用程序在总部和分支机构的本地服务器上运行。互联网连接并非每次都可用。客户通过这三个地点下订单。我的问题是,我想在这三个数据库之间同步数据并保持这三个数据库是最新的。有没有办法做到这一点?

采纳答案by sbrattla

I'm using SymmetricDS to synchronize databases. It is capable of synchronizing or replicating data between nodes (servers/databases), only pushing or pulling the data you define. It is a software based on Java, it has a steep learning curve, but it really does the job.

我正在使用 SymmetricDS 来同步数据库。它能够在节点(服务器/数据库)之间同步或复制数据,只推送或拉取您定义的数据。它是一个基于 Java 的软件,它有一个陡峭的学习曲线,但它确实可以胜任。

SymmetricDS can be set up to push changes from one node to the two other nodes, thus making sure that all three nodes contains the same data. You need to make sure that primary keys are unique keys, and not auto incremented values assigned by the database as this most likely will be an issue across the three different databases you'd like to synchronize.

SymmetricDS 可以设置为将更改从一个节点推送到其他两个节点,从而确保所有三个节点都包含相同的数据。您需要确保主键是唯一键,而不是数据库分配的自动递增值,因为这很可能是您要同步的三个不同数据库的问题。

The software installs triggers on the database, and captures changes when INSERT, UPDATE or DELETE (and other) operations are carried out. These data changes are then invoked on the other nodes. The software needs to run on each location, but does not need an internet connection that is available at all times.

该软件在数据库上安装触发器,并在执行 INSERT、UPDATE 或 DELETE(和其他)操作时捕获更改。然后在其他节点上调用这些数据更改。该软件需要在每个位置运行,但不需要始终可用的互联网连接。

I did worry in the beginning that triggers on all my tables would slow down performance, but this has not been a problem at all. I can't say that we've discovered any issues with performance after the triggers were installed.

一开始我确实担心我所有表上的触发器会降低性能,但这根本不是问题。我不能说我们在安装触发器后发现了任何性能问题。

Have a look at http://symmetricds.org/for more details.

有关更多详细信息,请查看http://symmetricds.org/