Slippery Snippets
Sunday, December 12, 2010
  Relaxing with CouchDB

I’ve been looking for an excuse to use CouchDB for a while. I forget where or when I first heard of it but I've been hooked on its feature set for some time now. Unfortunately I’ve not been able to think of a good app to write or I’ve been unable to fit my app into the CouchDB way of thinking.

Last month, however, I got pulled onto a piece of work where some sort of easy to use, replicating, eventually consistent application would have been really useful. So I decided that this would be the perfect opportunity to start a Couch app. But then I got stuck. I downloaded CouchApp, watched a couple of Evently screencasts and sat there repeating “CouchDB is relaxed. CouchDB is relaxed”. Couch sat there chilling out and I just got more stressed. So I’ve decided to start simple and build up a good base of fundamentals before trying the harder stuff.

So here is (I hope) a few posts about my first steps with Couch and how I got to the point where I started to relax a little.

Installation

Baby steps first. I’ve just rebuilt my work laptop. I’m now running Windows 7 with an Ubuntu VM. I want to make sure I use the VM more, so I decided to run Couch from there and connect to it over a host only network. Setting up the VMs network interfaces is left as an exercise to the reader but let’s do a simple walkthrough of the installation under Ubuntu. The latest version of Couch is 1.0.1. Let’s see what’s in the repos first:

me@ubuntu:~$ apt-cache search couchdb
couchdb-bin - RESTful document oriented database, programs
desktopcouch - A Desktop CouchDB instance
evolution-couchdb - Evolution support for CouchDB databases
libcouchdb-glib-1.0-2 - GLib-based API for CouchDB
libcouchdb-glib-dev - Development files for GLib-based API for CouchDB
libcouchdb-glib-doc - GLib-based API for CouchDB
libdesktopcouch-glib-1.0-2 - Glib-based API for Desktopcouch
libdesktopcouch-glib-dev - Development files for Glib-based API for Desktopcouch
python-couchdb - library for working with Apache CouchDB
python-desktopcouch-records - Transitional package, desktop CouchDB Records API
couchdb - RESTful document oriented database, system DB
desktopcouch-tools - Desktop CouchDB tools
gir1.0-couchdb-glib-1.0 - GLib-based API for CouchDB
gir1.0-desktopcouch-glib-1.0 - Glib-based API for Desktopcouch
libmoneta-ruby - Ruby interface to multiple key/value stores
libmoneta-ruby1.8 - Ruby interface to multiple key/value stores
python-desktopcouch - Transitional package, Python Desktop CouchDB
python-restkit - HTTP resource kit for Python
quickly-ubuntu-template - quickly ubuntu application template
xul-ext-bindwood - Firefox bookmark syncing with desktop couchdb
me@ubuntu:~$


Two likely candidates. The second looks like the best option as I want to make sure that this runs on startup and can be accessed from Windows with minimal effort.



me@ubuntu:~$ apt-cache show couchdb
Package: couchdb
Priority: optional
Section: universe/misc
Installed-Size: 84
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Erlang Packaging Team <pkg-erlang-devel@lists.alioth.debian.org>
Architecture: all
Version: 1.0.1-0ubuntu3
Depends: couchdb-bin (>= 1.0.1-0ubuntu3)
Filename: pool/universe/c/couchdb/couchdb_1.0.1-0ubuntu3_all.deb
Size: 12814
MD5sum: 12c56b05e323e9ef623379d139811c7e
SHA1: 0c894c4d37bd2126a00be797a20ea60c1d44d051
SHA256: 0572cad50d63d2576a404bba8b78636a604eb6899af3ab2738e65a6ff6e7a103
Description: RESTful document oriented database, system DB
Apache CouchDB is a distributed, fault-tolerant and schema-free
document-oriented database accessible via a RESTful HTTP/JSON API. Among other
features, it provides robust, incremental replication with bi-directional
conflict detection and resolution, and is queryable and indexable using a
table-oriented view engine with JavaScript acting as the default view
definition language.
.
CouchDB is written in Erlang, but can be easily accessed from any environment
that provides means to make HTTP requests. There are a multitude of third-party
client libraries that make this even easier for a variety of programming
languages and environments.
Homepage: http://couchdb.apache.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu

me@ubuntu:~$


1.0.1 in the repos? Perfect.



me@ubuntu:~$ sudo aptitude install couchdb
[sudo] password for me:
Sorry, try again.
[sudo] password for me:
Sorry, try again.
[sudo] password for me:
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B of archives. After unpacking 0B will be used.

me@ubuntu:~$


That’s a pretty useless bit of output, as I’ve already got it installed (plus you can see how bad I am at typing my password in) but you get the idea.



Now that Couch is installed we need to tweak the config to run on external interfaces. You’ll need to edit the /etc/couchdb/default.ini file and search for “bind_address”. I’ve changed mine to “0.0.0.0” which will listen on all interfaces. Don’t do this unless you want everyone on your network to be able to access your Couch instance. Change it to the IP address of your host only adapter if you’re running on a VM.



Now let’s test whether things are running okay:



[118]:> (New-Object System.Net.WebClient).DownloadString("http://192.168.23.130:5984")
{"couchdb":"Welcome","version":"1.0.1"}

C:\Users\Me
[119]:>


Who needs Curl, eh? A quick browse to http://192.168.23.130:5984/_utils/ will confirm that Futon is up and running. It’s good practice to create a new user so that we don’t operate in admin party mode but I’m not going to.



That’ll do for the first post. Next I’ll give an overview of the application I’m going to be working on and start working with CouchApp.

Labels:

 

Archives
July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / March 2007 / April 2007 / May 2007 / July 2007 / September 2007 / February 2008 / June 2009 / December 2010 /


Powered by Blogger

Subscribe to
Posts [Atom]