CouchDB-Lounge headaches
by nakubu at 2010-02-01 13:44:16

Anyone working with CouchDB for any large-scale project would probably like to be able to shard their database and/or use a cluster of couch instances. Those of you interested in doing this would most likely turn to CouchDB-Lounge. Unfortunately, getting Lounge to work is a huge pain in the ass. It took me a while to figure out why things weren't working, what packages I was missing and what code I had to alter (Lounge is not completely free of hardcoded configs!). There weren't too many useful sites out there, so this post is for all those out there struggling with CouchDB-Lounge and need some help. If I missed something, please comment.

Firstly, I'm assuming a fresh install of some Linux distro (I used ubuntu). Note: Configuring for OS X is different and apparently a bit harder to do for some reason. I was going down that path until I spoke with Randall Leeds (tilgovi, one of the Lounge devs) on the #couchdb IRC channel, and he warned me the install hasn't been properly tested on Macs, and more tweaking might be involved.

So, for dumbproxy to work, you need to download and compile json-c as directed on the Lounge wiki, but also remember to get the python-pyicu package. Once you get that running, read THIS. Fix this bug, otherwise, your nginx process will be running with the wrong config.

For smartproxy, you'll need python-cjson package, and for replicator, you'll need the pycurl package. I think I ran into more problems, but I'll check my logs and get back to this post in a bit.

Now here's the meat of the problem. After running this and setting up my shards.conf file to point to two couch instances on different ports, when I'd submit any request to the main lounge instance (running off port 6984), my requests were virtually ignored. So after running around reading the sparse documentation, the immense log files and reading the code, I found this line in

me = 'http://' + socket.gethostname() + ':5984/' (line 40)

which retrieved my laptop name, and completely ignored my conf files! So it was effectively trying to use http://malini-laptop:5984 as the main couch instance, and my laptop name didn't resolve to, so my requests were shot to nowhere. In the end, I fixed this by adding another section in my local.ini conf file that contained the URL for the main couch instance, and I changed that line to pull from the conf file. Beware of this problem if your configuration points to anywhere but (hostname):5984!

Aside from configuration problems, Lounge does what it's supposed to do, which is pretty sweet. I hope this prevented people from wasting their time trying to figure out what was wrong with their configuration:)

Ou, as a side note, it might be useful for those using python-couchdb to modify Server's 'create' method. Lounge uses nginx, and the current python-couchdb (0.6.1) seems to assume you're running Apache or some other web server, since it currently sends no headers with the PUT request. Nginx throws up HTTP errors when it sees that there are no headers (it assumes it's a chunked request, which it does not handle), so I patched it to send:

self.resource.put(validate_dbname(name), headers={'Content-Length':'0'}) [line 17]

This tells nginx that you're simply making a PUT request with no data.

Related tags:
couchdb, lounge, cluster, shard

nedu says:
2010-09-14 10:18:09

Hi nakubu,
Thanks for the useful post. does lounge work with windows? I am not able find any hints about installing it in windows.

name (required):




Find the squirrels below!