Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Online/Offline Database Synchronization - MySQL/PHP

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

  1. On internet
  2. Head office
  3. Branch office

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?

like image 837
iamsumesh Avatar asked Oct 11 '11 07:10

iamsumesh


People also ask

How can I sync my offline database online?

UploadData(dataRows/collection) - Windows service should call this on regular intervals and update the remote database. Each record in database will have a timestamp. For local update, get the largest timestamp and send it as parameter to GetData(). The webservice will return the records created after this time.

How do I make MySQL database offline?

You can use The embedded MySQL Server Library to access MySQL data files without running the MySQL server. Show activity on this post. You can setup a database to work on your localhost. This will be offline unless you setup the front-end stuff to let the internet interact with it.

How can I connect online database in PHP?

Open your browser and go to localhost/PHPMyAdmin or click “Admin” in XAMPP UI. Now click Edit privileges and go to Change Admin password, type your password there and save it. Remember this password as it will be used to connect to your Database.


1 Answers

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 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.

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.

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

like image 153
sbrattla Avatar answered Sep 19 '22 00:09

sbrattla