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.
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: couchdb
Your latest vimball has DOS line endings, and svn is still at the last version :(The reason SVN is the last version is that bzr-svn was not able to push the latest changes up to Google Code. Now I'd like to point out that this is most likely my fault; I noticed that the author of bzr-svn linked to one of my posts about how the plugin didn't work under Windows. Just to clarify - this was due to my lack of effort more than anything else.
I have installed an interesting application - BlogJet. It's a cool Windows client for my blog tool (as well as for other tools). Get your copy here: http://blogjet.com
"Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination." -- Albert Einstein
It also presents you with this as the default test post, so I’ll help the Google rankings and let it get posted. Hopefully this should allow me to post a little more. I’ve tried typing up some posts in Vim, but I think that this will be a better solution. Let’s see, eh?
def screenshot(self, id):
i = model.Screenshot.get(id)
if i:
im = Image.open(StringIO(i.image))
pylons.response.headers['Content-Type'] = "image/%s" % (im.format and im.format.lower() or 'bmp')
pylons.response.headers['Content-length'] = "%s" % len(i.image)
if request.params.has_key('thumb') and request.params['thumb'] == "True":
im.thumbnail(THUMB_SIZE, Image.ANTIALIAS)
w = StringIO()
im.save(w, im.format)
return str(w.getvalue())
abort(404)
Subscribe to
Posts [Atom]