CouchDB VirtualBox Development Environment

Posted by on March 27, 2009

I’ve most recently become infatuated with CouchDB.  After reading the free online book (a fantastic work in progress), watching the RubyFringe interview with Damien Katz, and Jan Lehnardt’s presentation from MountainWest RubyConf 2008 I decided I was being lazy.  Too much input and not enough output. However, I did feel a bit more prepared to dive in.

There are several ways & platforms to which you may install CouchDB. The project wiki is a good resource to most installation methods, but I wanted a little different flavor; a little added complexity…  My installation goals are two-fold:

  1. Sandbox’d:  I prefer to keep my computer as “clean” as possible. I only install as little as necessary for a core development environment. I don’t like installing or running extra services or whatnot when they aren’t frequently used; especially when I’m just checking something out.
  2. Familiarity:  If I’m going to spend time learning a new project’s installation and configuration I prefer to learn it once.  I don’t necessarily want to install it one way on my laptop and then deploy to a server another way.

To do this I used VirtualBox to create a Ubuntu server VM that I would install CouchDB on.  This configuration accomplishes both goals as the VM provides a local sandbox and using Ubuntu server brings familiarity as it is my choice distro for use in the wild.  This isn’t rocket science, but I do think it allows someone to create a consistent installation regardless of their development computer’s platform; given VirtualBox supports it.

The Setup

After following these steps you’ll be able to access and code against (from your normal development environment) a CouchDB server running on an Ubuntu Intrepid VM using VirtualBox.

  1. Get VirtualBox.  If you already have it then I’d recommend upgrading to the latest version as this setup refers to version 2.1.4
  2. Download Ubuntu (8.1.0) Server Edition ISO.
  3. Create a new Virtual Machine.  I’m not going to step this out, but here are some pointers:
    • I allocated 256MB Memory to match my 256 slice on slicehost
    • I’m using a dynamically expanding up to 5GB “Virtual Hard Disk”
    • After creating the VM click open the settings and under “Storage” -> CD/DVD-ROM mount the Ubuntu ISO you downloaded.
    • Start the VM, walk through the Ubuntu install.
    • Unmount your Ubuntu ISO and restart your VM again.  Make sure you can login.
    • If you get an error that you need to “use a kernel appropriate for your CPU” then power off the VM.  Go into the VM’s settings.  “General” -> “Advanced” and check “Enable PAE/NX”.  Start it up again.
  4. Install CouchDB. Log in to Ubuntu and execute: sudo apt-get install couchdb
  5. Configure CouchDB.  Edit /etc/couchdb/couch.ini and change the “BindAddress” from 127.0.0.1 to 0.0.0.0 - This allows us to access the CouchDB server from our “host”/main computer.  CouchDB only accepts local requests by default.
  6. Shutdown Ubuntusudo shutdown -h now
  7. Share your network. Open the VM settings and under your Network -> Adapter set “Attached to:” “Host Interface” Doing this will assign your VM a local network IP that you can use to access your CouchDB server. Make sure you select the correct “Host Interface” (ethernet/wireless adapters) from the list.
  8. Fire it up. Boot Ubuntu, login, execute <code>ifconfig</code> and note your VM’s IP address.
  9. Relax.  Check out the Futon by browsing to http://[VM's IP Address]:5984/_utils

You now have a “sandbox’d” installation of CouchDB running on Ubuntu and accessible at http://[VM's IP Address]:5984.

As of this post’s publish date the Ubuntu APT CouchDB package installs version 0.8.0-incubating.  If you would like the most current version you will need to build from source which is explained on the wiki.
3 Comments on CouchDB VirtualBox Development Environment

Respond | Trackback

  1. Tim Parkin says:

    nice work.. good timing for apachecon too..

  2. Doug Matthews says:

    excellent tutorial, I have couchdb up and running in no time
    many thanks!

  3. [...] CouchDB VirtualBox Development Environment [...]

Respond

Comments

Comments: