0

Okay so here's my scenario. I have two applications that share some tables from the same DB. Let's call them App1 and App2. Lets also assume the DB used here is called DB1. App1 and App2.

App1 is on the same machine as DB1. App2 is on a different server but connects to DB1 remotely via PHP. This setup sometimes slows down access to DB1 from App2 and causes timeouts.

I will be creating DB2 which will be a replica of DB1 and hosted on the same machine as App2. This DB2 should be automatically synched with DB1. Changes are only going to made on DB1, so just need to push changes to DB2 regulary.

How can I do this? I'm assuming the solution to do this will be using cron jobs and PHP but I do not know what code can help do this.

Thanks all!

I am hoping someone has already done something like this and can share what they did.

1
  • Setup master-slave replication between DB1 and DB2.
  • APP1 reads and writes to DB1.
  • APP2 reads from DB2.
  • APP2 writes (if it does) to DB1.

Note that APP2 will read eventually consistent data and it will have to handle writes to DB1 itself. (I do not tend to like master-master replication setup and writes to both ends due to past experiences but it is also an option.)

You said no links but below this link includes steps for setting replication, you might want to refer.

|improve this answer|||||
  • Thanks. Do I have configure the slave's my.cnf? The problem is I can do this on the master as I have the DB installed locally but the APP2 is installed on a shared hosting server so I don't have access to configuration. I should've probably mentioned that! – Amjad Sep 16 '15 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.