0

Right now I have create tiny php script that connect to hostA.db1 and fetch a record to hostB.db1 via CRON jobs every 1 minutes. That script contain the process that make a comparing the count number between both host database then if some of record is less then the insert script will be triggered.

Instead of using CRON jobs, is there any way we can fetch a record from different host database in a real-time? For example, if there are a new record available then some action will call the script to fetch only new record into hostA loaded into hostB without waiting any scheduler process.

If you have any idea, please describe benefit or pros/con using that technique..

mf.zull
  • 41
  • 5
  • 2
    Maybe I misunderstand your intentions, but would [replication](http://dev.mysql.com/doc/refman/5.7/en/replication-howto.html) not work for you? – Iskar Dec 15 '16 at 09:58
  • Is that **replication** technique can be update automatically when a new record available from master then loaded into slave? How to trigger that action? Any helpful resource are available for that? I believe this technique need to create a bind configuration in a both between **hostA** and **hostB**. – mf.zull Dec 15 '16 at 10:38
  • Replication is designed to work by sending the "binary log" from master (hostA), to the slave (hostB). So any modifying commands that are run on master will be sent to be run on the slave. This will keep hostA and hostB in sync; usually _close_ to real-time, but not fully so. If I understand your initial question, replication is what you want. Please clarify your intentions instead of just specifying your goal, if I am missing your point, thanks. – Iskar Dec 15 '16 at 10:53
  • I'll also add a note that this question is screaming "replication". If that doesn't do what you need, you'll need to expand a little more. Otherwise look at federated tables where you can query one server to get results from a second server as if it was the first server (with limitations). – Robbie Dec 15 '16 at 23:19
  • Just had a requirement changes, looks like some data need to be modify first after loaded into slave DB (HostB). What was limitation for CRON job in CPanel? Any other way or using Perl / Web Service / socket.io ? – mf.zull Dec 16 '16 at 01:06
  • 1
    Possible duplicate of [PHP regular backup of mysql data](http://stackoverflow.com/questions/38916163/php-regular-backup-of-mysql-data) – e4c5 Dec 16 '16 at 05:26

0 Answers0