CouchDB from Src How-To

Well this was more effort than it should have been. I have been dabbling with Erlang for

Media_httpwwwstrangea_gvfsh
a while, and after struggling with MySQL, Tomcat and JDBC I was looking for an alternative web-app stack. CouchDB looks to be perfect, although sufficiently new that there is not a lot of documentation, both of the books available right now are OK, but not brilliant. In general I prefer the style of CouchDB: The Definitive Guide but prefer the examples from Beginning CouchDB. My personal preference with programming and software tool books is that they should provide detailed, hand-held, speak-to-me-like-I-am-an-imbecile walk-throughs of the most common basic use cases. Anyhow, CouchApp looks like a great way to develop apps for CouchDB, although documentation is fairly sparse. The main problem I found is that the versions of Erlang and CouchDB available from repositories for both Ubuntu and Debian are way behind the cutting edge to the point that the examples in the books won't run. I found that the best way to set up my CouchApp development environment is to completely avoid the repositories and build from source in a clean Ubuntu server VM using the following steps:

  • $ apt-get update
  • $ apt-get clean
  • $ apt-get upgrade

We are going to be building some software so the following tools are useful:

  • $ sudo apt-get install build-essential subversion git-core openssh-server

Install Erlang

Install CouchDB

  • $ sudo apt-get build-dep couchdb
  • $ sudo apt-get install xulrunner-dev libicu-dev libcurl4-gnutls-dev libtool
  • $ wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org/couchdb/1.0.0/apache-couchdb...
  • $ tar zxvf apache-couchdb-1.0.0.tar.gz
  • $ cd apache-couchdb-1.0.0
  • $ ./configure
  • $ ./configure --with-js-lib=/usr/lib/xulrunner-devel-1.9.2.3/lib --with-js-include=/usr/lib/xulrunner-devel-1.9.2.3/include
  • $ make CouchDB
  • $make
  • $sudo make install

Final Setup & Running CouchDB

  • $ adduser --system --home /usr/local/var/lib/couchdb --no-create-home --shell /bin/bash --group --gecos "CouchDB Administrator" couchdb
  • $ sudo chown -R couchdb:couchdb /usr/local/etc/couchdb
  • $ sudo chown -R couchdb:couchdb /usr/local/var/lib/couchdb
  • $sudo chown -R couchdb:couchdb /usr/local/var/log/couchdb
  • $sudo chown -R couchdb:couchdb /usr/local/var/run/couchdb
  • $sudo chmod -R 0770 /usr/local/etc/couchdb
  • $sudo chmod -R 0770 /usr/local/var/lib/couchdb
  • $sudo chmod -R 0770 /usr/local/var/log/couchdb
  • $sudo chmod -R 0770 /usr/local/var/run/couchdb
  • $ sudo ln -s /usr/local/etc/init.d/couchdb /etc/init.d/couchdb

Put xulrunner-devel on your LD_LIBRARY_PATH

  • $ sudo touch /etc/ld.so.conf.d/couchdb.conf
  • $ sudo cat > /etc/ld.so.conf.d/couchdb.conf
  • /usr/lib/xulrunner-devel-1.9.2.6 (NB. Check the version that you have installed!)
  • <CTRL-D>
  • $ sudo ldconfig

Running CouchDB Manually

  • $ sudo -i -u couchdb couchdb

Running CouchDB As a Daemon

  • $ sudo /etc/init.d/couchdb start
Posted
 

Bash Quoting

Media_httpac22001comp_tkfqr
I found a couple of articles over at the Linux Journal that will give you a bit more understanding of the wonders of quoting in Bash. The first article will probably be of more use to you as it deals with the basic of quotes in scripts whereas the second article deals more with the intricacies of quoting within scripts, in their example, scripting interaction with a MySQL database.
Posted
 

The Year We Make Contact

Media_httpwwwstrangea_bdhjq
According to Arthur C. Clarke anyway. My own blogging has had to take a back seat over the past month as I have been busy with teaching related activities and getting the websites associated with my various courses up and running again after an over enthusiastic rm-ing session on the wrong web server last summer. I had kept MySQL dumps of everything but not of the various sites themselves so I had the content but not the presentation and it takes time, a precious commodity, to get these things going. Anyway my argumentation site is up and running, as is my linux site and my agents site, covering the three broad topics that I am teaching this year. The plan has been to use publically accessible blogs, rather than blackboard, to keep a record of everything that occurs in relation to each of my modules. I have an adverse reaction to the locking up of knowledge inside little blackboard websites because they are distinctly not open. When I have been interested in various modules being delivered by my colleagues I have had to go through a process of getting added to the module lists so that I can get access. When all I really want to do is read through the slides to satisfy some sort of academic craving. What are the plans for this year you wonder. Well no resolutions. Some half-hearted, fairly vague, back of the mind ideas for things I want to do over the next year or so. Some of these things are fairly practical;
  • getting to inbox 0 (currently at inbox 2 as I have 2 emails from friends that I want to give thoughtful and considered replies to) and other hacks to increase my productivity,
  • getting a fellowship application in (although this is actually half-hearted as it would mean little or no teaching for 3 years or so and I now realise that it is the healthy balance of teaching and research activities that currently make me (reasonably) happy in my job),
  • getting some research funding (this is more whole hearted as I want to stop self-funding my visits, get some better equipment and books, and because it is a necessary part of getting onto the career ladder as a scientist - it is not solely about what you know but increasingly about how much money you can bring to the table),
  • getting those two journal papers off of my desk that have been in various states of done-ness for too long,
  • getting my small publishing business up and running (as it has been in the back of my mind for a couple of years during which time several friends have written and print-on-demanded various books but would rather have turned that over to someone they know to manage so that they could write more). It should be noted that this is also a strategic move in that it looks increasingly as though only those who have a business interest in copyright will have any say in the near future over how the copyright landscape erodes. By developing a non-traditional publishing model based off of openness and sharing perhaps it will give me a stronger basis from which to argue against increased restrictions,
  • finally get my personal consultancy changed over from a sole trader business into a limited company and try to build an extra income stream,
  • get some new websites up and running. I have one on cooking (partnering with a friends baking website (which I also have to get running)), one for the publishing company, and one for my book blogging.
I think that that is enough to get started with...
Posted