We Talk Coding

How to Connect two databases in two different computers ?

I need to develop a system using HTML, PHP, Apache. The system will have two databases in two different locations. Once in 24 hour one database will call/connect with other one and update so there can be no data inconsistency. How do I do that. I have worked in database system before but those are stand alone type not like distributed. Need more than suggestion. Coding will be greateful help but pointing out (beside coding, showing what to do) will also help. HELP !!!!

Public Comments

  1. Distributed Databases would be the wrong term for your actions. A distributed database takes the collection of data and distribute them among several databases, it as well separates partiions and different segments. I think you mean you want to mirror databases, there area two things you should be doing when doing a database mirror. under the /mysql/bin/log directory there is logs.. And There is a mysqldump feature to backup your entire webpage. Now what you could do is create a crontab that executes every 24 hours. What that scheduler does is that is executes the mysqldump function ( mysqldump -uroot -p --alldatabases > thisfile.sql ) Once you do that it will save the file to your hd, and then you can make a simple script that moves that file to the other database.. BUT if your using mysql you could do mysqldump -h HOST -u USER -p PASS --alldatabases > thisfile.sql Take a look at the mysql dump feature. But what if your server crashes and didn't record the 24 hours of stuff? then there is a folder within .mysql/bin/logs that contains all the logs of mysql.. What you could do is that transfer those logs as well to the other server and just run those logs when you want to recover one day.. This is a complex problem, many ways to do it, but I hope I helped.. Good Luck
Powered by Yahoo! Answers