Question

I am creating a website and am expecting somewhat normal usage. I am setting up the system for now with 1 Apache Server and 2 DB servers. I want any DB operations to be reflected in both DB servers so that I can have 1 server as Backup. Now how do I do it ?

The ways I can think of are :

  1. Perform same operations in both DB from PHP. This seems like a terrible idea.
  2. Update 1 DB and sync both DB servers periodically. This seems better.

Is there any better way to achieve this ? How is it done in Enterprises ?

Was it helpful?

Solution

If you're using MySQL, there is quite powerful built-in replication.

Check out the docs

OTHER TIPS

A terrible idea is to have backup each time a new operation happens. No modern, nor old application works this way. Even Windows System Restore makes backup on scheduled times, not on each operation.

I'd suggest you to make an sql dump script. And schedule a cron job wich will run it once a day, or twice a day. If you really need the data on the server immediately (assuming, you need if one of the DB servers crashes, your app continue working immediately with the backup server) you can make an import script, which will run once the dump finishes.

If you are not in the special case, when you need once the first DB server is shutdown'd, to have another one opened, you can just store the dumped sql files on the machine and not load them on real database, if they are not needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top