This topic is locked
[SOLVED]

 Using PHPrunner with MySQL SLave Server

4/3/2015 3:21:48 PM
PHPRunner General questions
M
mrphp author

I have 2 servers, server A and server B. Server A runs MySQL as a master and uses PHP to access it's data - pages created with PHPrunner 7.1. Server B is running MySQL as a slave to server A. It's the backup server should server A fail. Every evening the files in the html directory on server A are copied to the html directory on server B. So, both servers have the same data and either can be used to access the data in MySQL via PHP.
This works great except I don't want anyone to inadvertently write data to server B since it is the slave - I would like it to be read only and I'm having trouble determining how to do this.
When web pages created by PHPrunner access a MySQL database are the credentials used on the Connect page of the PHPrunner software the credentials they use to access MySQL?
My thought is to create a MySQL user on server A with privileges to read, write, delete, etc. and use this user for the connection in PHPrunner. I then would create the same MySQL user on server B but with only Read privileges.
Will this work?
Thanks.

Sergey Kornilov admin 4/3/2015

In general it would work. I can imagine though that would a huge usability issue as users will be still able to use add/edit/delete functions and getting all kind of errors due to insufficient permissions or this user on the second server. This may not be an issue for emergency plan but smarter approach would be to hide all editing functions from the end user once you are switching to the backup server. Your application needs to be smart enough to recognize this situation and to hide add/edit/delete functions.

A
Abul 4/4/2015

Why don't use Federated db function for MySQL? That means, from DBA point of view you can make server A as your replicated db call federated db on server B (B will be your original db). Now connect your application to the federated db on server A. db on A should connect to the db on B through local host connection under firewall for safety. your application will connect to the federated db on server A.

M
mrphp author 4/7/2015



In general it would work. I can imagine though that would a huge usability issue as users will be still able to use add/edit/delete functions and getting all kind of errors due to insufficient permissions or this user on the second server. This may not be an issue for emergency plan but smarter approach would be to hide all editing functions from the end user once you are switching to the backup server. Your application needs to be smart enough to recognize this situation and to hide add/edit/delete functions.

M
mrphp author 4/7/2015



In general it would work. I can imagine though that would a huge usability issue as users will be still able to use add/edit/delete functions and getting all kind of errors due to insufficient permissions or this user on the second server. This may not be an issue for emergency plan but smarter approach would be to hide all editing functions from the end user once you are switching to the backup server. Your application needs to be smart enough to recognize this situation and to hide add/edit/delete functions.


The users aren't actually aware of the second server. It would only be used if the first server went down. I just thought it would be good to be read only just in case. I'm only interested in the information being available in case of a server "A" failure - no need to ever write to it. I can see your point though about people being confused at that point.
Thanks for your help.

M
mrphp author 4/7/2015



Why don't use Federated db function for MySQL? That means, from DBA point of view you can make server A as your replicated db call federated db on server B (B will be your original db). Now connect your application to the federated db on server A. db on A should connect to the db on B through local host connection under firewall for safety. your application will connect to the federated db on server A.


I'm not familiar with the Federated engine but your idea sounds interesting.

I'll have to do a little digging when I have some time.
Thanks.