Access Keys:
Skip to content (Access Key - 0)
Welcome to Muck and Brass, the Snowtide blog site    

Clearing some hurdles automating CouchDB administration

Authored on Apr 23, 2010 07:58 AM by Chas Emerick ; last touched on Apr 23, 2010 07:58 AM

Labels

clojure clojure Delete
couchdb couchdb Delete
devops devops Delete
pallet pallet Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

I ran into a couple of administration issues with CouchDB while working on support for it in the excellent Pallet project 1 , so I thought I'd leave some breadcrumbs for those that follow.

(Note that these issues were experienced with CouchDB 0.10.0 on Ubuntu Karmic. They may be resolved in later versions of CouchDB or Ubuntu, but those are the versions we're targeting for now.)

Broken Directory Permissions

First, Karmic's couchdb package is broken, insofar as key directories that CouchDB uses don't have the right ownership or mode. The symptom of this is that CouchDB will not stop properly when one invokes /etc/init.d/couchdb stop. This is a known issue, and will hopefully be resolved for Ubuntu Lucid. Rumor has it that some versions of CentOS have the same issue.

The fix is simple:

chown -R couchdb:couchdb /var/log/couchdb /var/run/couchdb /var/lib/couchdb /etc/couchdb
chmod 0770 /var/log/couchdb /var/run/couchdb /var/lib/couchdb /etc/couchdb

That's a bit of a carpet-bombing, but certainly won't do any harm, and does the trick (adjust for the install dir you have, e.g. perhaps prefixing everything with /usr/local).

CouchDB only detaches when started from a full shell

This is where the world will learn that I'm mostly an idiot when it comes to shell stuff and sysadmin in general. Thanks go to Hugo Duncan for giving me a key hint that allowed to get past this one.

In short, pallet was doing the equivalent of this in order to invoke the scripts it generates for configuration management, etc. (assuming here that your user has NOPASSWD in /etc/sudoers:

ssh -t 192.168.0.105 'sudo /etc/init.d/couchdb start'

So, we're allocating a tty, which many services need around in order to fork and detach properly (such as Tomcat via jsvc, for example). However, the CouchDB server that is started with this command dies along with the ssh session. Go ahead, give it a shot. If you really want proof, you can do this to see that the server is running before the session is closed out:

ssh -t 192.168.0.105 'sudo /etc/init.d/couchdb start;sleep 1; curl http://localhost:5984'

Of course, if you log into an environment with a full interactive session, starting CouchDB and then logging out will leave the server running as one would expect.

The solution is painfully simple in this case – just don't invoke /etc/init.d/couchdb start as an ssh exec command. Whatever you're using for configuration management, have it run in a full interactive shell session. That's exactly what Pallet is now doing for all of its configuration executions.

Results

The CouchDB crate in pallet is now pretty well bullet-proofed...or so I hope.

Founder, Snowtide Informatics

About Me

I'm the founder of Snowtide Informatics. We make DocuHarvest, a web application that turns your valuable documents into data, and PDFTextStream, a PDF text extraction library for Java and .NET. I do a lot of programming in Clojure and just a little in Java, trying to make it easier for people to make unstructured content just a little more useful.

FYI, I'm now doing all my writing over at http://cemerick.com, so go there for my new stuffs. I'll be migrating much of the content from here over there gradually/eventually.

    Topics

    Archives

    1. 2010
      1. August
      2. June
      3. March
      4. February
      5. January
    2. 2009
      1. December
    Footnotes
    Reference Notes
    1 Pallet is a tool/framework for compute node provisioning as well as configuration management and general sysadmin automation. I'm not aware of any similar provisioning automation frontends (except for jclouds, which Pallet wraps / uses), but I'd otherwise characterize Pallet as a mashup of chef + capistrano, but written in Clojure (yay!).

    blog comments powered by Disqus

    Adaptavist Theme Builder (3.3.5-conf210) Powered by Atlassian Confluence 3.0.2, the Enterprise Wiki.