Trond Norbye's Weblog

« Previous day (Sep 1, 2008) | Main | Next day (Sep 2, 2008) »

http://blogs.sun.com/trond/date/20080902 Tuesday September 02, 2008

Memcached UDF for MySQL on OpenSolaris

I have been hearing about the Memcached UDF for MySQL for a while now, so I decided to spend some time playing with them. Being the geek I am, playing for me is to get my hands dirty with the code so I cloned the source repository from: http://hg.tangent.org/memcached_functions_mysql/.

With the source code and a cup of coffee available I ran:

trond@opensolaris:compile> ./config/bootstrap
trond@opensolaris:compile> ./configure CC=cc --with-myslq=/usr/mysql/bin/mysql_config
[... cut ...]
checking for DEPS... configure: error: Package requirements (libmemcached >= 0.17) were not met:
[... cut ...]
    

I know that there is a version of libmemcached in OpenSolaris (I was involved during the integration), so the version is either too old or configure isn't picking it up..

trond@opensolaris:compile> pkginfo -l SUNWlibmemcached | grep DESC
      DESC:  memcached C API 0.16
    

It turns out that the version of libmemcached integrated in OpenSolaris is too old, so I filed 6743510 to get it upgraded.

I have been contributing to libmemcached (adding support for the binary protocol), so I have a "fresh-from-the-oven" version installed in /opt/memcached". All I needed to do was to get the configure script to pick it up... There was at least two different roads I could go:

  • I could just comment out the test in configure.ac, regenerate the configure script and run it as:
    trond@opensolaris:compile> ./configure CC=cc CFLAGS=-I/opt/memcached/include \
           LDFLAGS="-L/opt/memcached/lib -R/opt/memcached/lib" \
           --with-myslq=/usr/mysql/bin/mysql_config
          
  • I could do it the "clean" way and be nice to the community and add a: --with-libmemcached option

For unknown reasons I decided to do it the clean way and submitted a patch back to the project (use hg import if you would like to use it before it is included in the upstream repository).

With the lib installed as /opt/memcached/lib/libmemcached_functions_mysql.so, I tried to figure out how to load it in MySQL. The documentation told me to copy the library to /usr/local/mysql/lib/mysql/plugins/, but my OpenSolaris delivers MySQL in /usr/mysql so I tried to copy the file to /usr/mysql/lib/mysql/plugins/ without success.

A quick truss on mysqld revealed that it did not search any other directories than ld does. Being a MySQL novice I didn't know if my setup was mis-configured or not, so I returned to the MySQL documentation and found the following page. I don't want to expose the library to everything on my system, so creating a link from /usr/lib or using crle was out of the question. Instead I modified /lib/svc/method/mysql and exported LD_LIBRARY_PATH.

I am now able to use the Memcached UDF for MySQL on my OpenSolaris box, but I don't like the LD_LIBRARY_PATH hack so I am looking forward for the MySQL 5.1 release. Perhaps I should try to compile a version myself and test it out.


Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.