SQLRelay MySQL compatibility layer in php-cgi.
Posted
by sybreon
on Server Fault
See other posts from Server Fault
or by sybreon
Published on 2010-01-01T07:02:52Z
Indexed on
2010/03/09
11:38 UTC
Read the original article
Hit count: 421
I am investigating the use of sqlrelay as a middle-layer between an application that uses MySQL with a PostgreSQL backend. I assume that this is something that it can do to ease backend migration. But for the moment, I am just experimenting with a MySQL application accessing a MySQL backend through the sqlrelay layer.
app => sqlrelay lib => mysql client lib => tcp => mysql server
I followed the instructions for the MySQL drop-in replacement and it works. I can connect to the backend MySQL server using both sqlrsh
and mysql
client application. It will work for most MySQL applications by using LD_PRELOAD
with the compatibility layer library.
The instructions recommend re-compiling php to support it. I would prefer not doing something so drastic. They also recommend setting the LD_PRELOAD
for apachectl
as a method for the apache/php stack. However, this does not work with lighttpd/php-cgi. I have wrapped php-cgi
with a shell script that sets LD_PRELOAD
before running the cgi script.
LD_PRELOAD=/usr/lib/libmysql50sqlrelay-0.39.4.so.1 /usr/bin/php5-cgi $@
I can see LD_PRELOAD
correctly set in phpinfo()
but the cgi scripts all fail and are unable to connect to the database. According to the mysql
client, the compatibility library should report itself as a 5.0.0 client but the phpinfo module reports itself as the actual 5.0.51a client library used. This means that the compatibility library was not used.
Is there someone who has had some success doing something similar?
© Server Fault or respective owner