I'm the developer of my employers corporate private website, a HTML5/PHP/CSS powered site for company reports etc. The site, hosted on a shared hosting package, connects to a remote read-only MySQL DB server for authentication and report data queries. This remote DB is mainly used by a separate windows exe.
The remote DB goes down frequently which of course causes the private website to bomb out on a MySQL connection error. I've thought about replicating the remote DB to the site's local hosted MySQL DB and using the local DB as the site's primary and only DB connection.
Is there a way of synchronising the remote DB to the site's shared hosting DB in a simple and pain free way? Like every hour it updates or something?
Or is there a function where the site's hosting package MySQL DB functionality can cache the remote DB data and use that as a fallback.
Thanks in advance.
-
my replication should be enough for you Read dev.mysql.com/doc/refman/5.6/en/replication.htmlRodrigo Gonzalez– Rodrigo Gonzalez2014年07月29日 21:56:48 +00:00Commented Jul 29, 2014 at 21:56
-
Replication seems unlikely to be a possibility in this case, depending on what exactly OP means by "shared hosting."Michael - sqlbot– Michael - sqlbot2014年07月29日 23:25:16 +00:00Commented Jul 29, 2014 at 23:25
-
@Rodrigo - Thanks for the guide I'll look at that now. @ Michael - The shared hosting is a namecheap pro shared linux hosting account. [link] namecheap.com/hosting/shared.aspx [/link]user44632– user446322014年07月30日 13:28:36 +00:00Commented Jul 30, 2014 at 13:28
2 Answers 2
Check here (http://drcharlesbell.blogspot.cl/2011/06/comparing-databases-with-mysqldbcompare.html)
It explain how to Compare-Copy a DB to another DB, my case is the same as yours.
Depending on your access level you can:
- Use a external client as middle man (to make de compare-copy)
- Script in PHP to check new lines in the original DB and copy them
- Use one of the many tools of MySQL to copy
MySQL replication can be helpful. Your remote DB (lets call it A) and Future DB on local site (lets call it B) can be configured with Master-Slave replication.
"A" will be master and "B" will be slave (Read Only)
How Master Slave replication works? Basically Whatever changes happens to the master ("A") will be logged into binary logs and further it will be transferred to the Slave server ("B") in asycronous manner. Further the slave will apply those transactions/changes to itself.
Note : You cannot use Slave .i.e. "Server B" for writes.
Let me know if you need detailed steps to configure Master-Slave replication.
Hope this helps.
-
Hi @V_K thanks for your reply. I tried to set up master-slave replication. I have a remote database and local database. Setup is up and running but data on a slave isn't syncing with the master database. Do you know any good source or any idea how can I solve that?Rutvij Kothari– Rutvij Kothari2017年12月20日 04:08:55 +00:00Commented Dec 20, 2017 at 4:08
-
can you please share details. Data sync speed is the issue? or data sync is not working at all?. Also share the steps you have performed to setup Master-Slave and below command output. show master status \G ---(On master) show slave status \G ---- (On slave)Vaibhav– Vaibhav2017年12月22日 08:28:01 +00:00Commented Dec 22, 2017 at 8:28
-
Hey @V_K thanks for your comment. I was having a different type of problem. Which I solved eventually. Thanks for your input. :)Rutvij Kothari– Rutvij Kothari2017年12月22日 22:02:08 +00:00Commented Dec 22, 2017 at 22:02
-
happy to know @RutvijKothariVaibhav– Vaibhav2017年12月26日 06:34:33 +00:00Commented Dec 26, 2017 at 6:34