Peter Cooper : UK Web 2.0 and Ruby on Rails consultant
Recent Posts
»Jay-Z: From Brooklyn to the Boardroom
»Prank Caller Submits Girl To Sexual Torture By Proxy
>Full archive
Other Posts
« Crap geek joke of the weekFixing Perl 5.8.6 issue on OS X 10.4 Tiger »

Installing memcached on OS X 10.4 Tiger


Installing memcached on Tiger is not the easiest of things to do. I started twenty four hours ago, and while I haven't spent all that time playing, it has definitely taken a couple of hours out of my day. So here's how to do it.



If you haven't got DarwinPorts, go get it and install it. They've just unleashed 1.0, so it's worth doing anyway. The downside to using DarwinPorts is that the versions of libevent and memcached are not the most recent.. but, at least they compile. Trying to get the regular sources to compile is very very hard, and I've tried for hours to do so. I keep getting complaints that the System framework is not a valid library file. This is Tiger specific, as it does not occur in Panther. May 7: Fixed. Install gcc 4 from the Tiger DVD and you can compile libevent from the latest sources!

Without further ado..

Install libevent. It's a dependency of memcached.

sudo port install libevent

Install memcached.

sudo port install memcached

Set an environment variable to stop libevent using kqueue (should force it to use select, which is slower, but actually works).

export EVENT_NOKQUEUE=yes

Run memcached (this gives it 24MB of memory max, and puts it on port 11211 - note that specifying a hostname will not work on OS X):

memcached -d -m 24 -p 11211

memcached is now running, you can test it by telnetting to port 11211 on localhost and doing some gets and sets. If you can connect multiple times to the daemon, you are good to go with whatever language/library you care to use (I'm using the Perl Cache::Memcached library).

Note: If your memcached dies after a single connection (that is, you can't make a second one), your memcached is probably still using kqueue.. which export EVENT_NOKQUEUE=yes should override. Make sure this environment variable is definitely set before rerunning memcached.


May 04, 2005 | Posted by peter | Comments (1)
Comments

This was very helpful. Thank you!

Posted by: Ryan Holm at May 5, 2005 05:20 AM

Return to the homepage.
Privacy Policy