Run script on remote server when new entry is in Mysql

Asked

Viewed 55 times

0

For security reasons, I have two servers. In one is hosted the site with the entire user interface and DB Mysql, and in another is hosted the application that will run the script from the user request. I need that when the user makes a request through the website, this request goes to the database on Server 1 and it sends the information to Server 2 that will execute a script inside the application with the information sent by Server 1. Here I designed the structure to get a better understanding: Estrutura

Is there any way to do this? Every new entry in Mysql on Server 1, Server 2 runs a script?

Edit1: Ricardo, thank you for the suggestion. I tried it in two ways:

  • insert the information into S1 and replicate it to S2 by binary log.

  • run a Trigger on S1 that sent the information to S2 through FEDERATED.

In both situations would, through this insertion in S2, run a Trigger that would call the script by UDF.

Unfortunately I could not put in practice because I do not have access to the S1.ini file, making it impossible to activate the binary log or the FEDERATED plugin.

A possible solution is to send the data simultaneously to the two servers and ,only in S2, create a Trigger that will run the script through UDF.

  • this "all new input" can be detected using a trigger, and within the trigger can execute a script

  • Ricardo, thanks for the answer! But is there a way for a Rigger to call the execution of a php on a remote server? Trigger wouldn’t just be for running scripts on the server itself?

  • you need to run Trigger on the remote server. A solution would be, a Trigger server 1 that writes to a table on server 2, and this one has a Trigger in this table to run a script

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.