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

2023-09-08 09:41:18 作者:每个男孩都不是公主?

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

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

在互联网上总部分公司

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

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?

推荐答案

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

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 可以设置为将更改从一个节点推送到另外两个节点,从而确保所有三个节点都包含相同的数据.您需要确保主键是唯一键,而不是数据库分配的自动递增值,因为这很可能是您要同步的三个不同数据库的问题.

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.

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

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.

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

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.

查看 http://symmetricds.org/ 了解更多详情.

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

 
精彩推荐
图片推荐