本文介绍了在线/离线数据库同步-MySQL/PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

  1. 在互联网上
  2. 总部
  3. 分公司

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

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(和其他)操作时捕获更改.然后,在其他节点上调用这些数据更改.该软件需要在每个位置运行,但不需要始终保持可用的Internet连接.

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.

这篇关于在线/离线数据库同步-MySQL/PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:43