Hi,
I hope i'm writing in the good mailing list...
Since one year, i'm working on loadbalancing solution for webservers
(usually Apache 2). Behind a cluster of http servers, we can find a
mysql cluster.
Generally ppl are using the mysql_connect with the hostname =
"localhost". When i suggest a loadbalancing solution, the mysql
database is hosted on a different server. So webpages of all virtual
hosts need to be updated to connect on the new hostname; which can be
very annoying.
I've patched PHP, and added 2 variables in PHP.ini which are :
mysql.unix_socket = On|Off
mysql.force_host =
The first one can disabled the connection on mysql unix socket and
transform "localhost" in "127.0.0.1". This allows to redirect mysql
traffic with iptables. Like :
iptables -t nat -A PREROUTING -p tcp --dport 3306 -d 127.0.0.1 -j
DNAT --to-destination <ip cluster>
The second force mysql_connect to one database whatever the hostname
specified in the mysql_connect function. This setting can be configured
for all or just for one virtual host.
I've already posted on php internal mailing list. Some ppl seems to be
interested.
I think it can be someting helpful for System Administrators. Tell me
ur feelings about this. If u think that's something good, then we may
apply these changes to mysql extension.
PAGES Vincent
System Administrator
France
| Thread |
|---|
| • Mysql + PHP : force hostname and disable unix socket | PAGES Vincent | 9 Jun |