Thursday, March 18, 2010

Edge CouchDB on Debian

‹prev | My Chain | next›

Tonight I continue my efforts to get CouchDB 0.11 running in a virtual machine.

Last night, I got through the process of creating a base Debian image in VirtualBox. The process does not take too long, but long enough that I would be quite happy to skip it in the future. So the first thing that I do tonight is clone the image for future use:
cstrom@whitefall:~/.VirtualBox/HardDisks$ VBoxManage clonehd couch-0.11.vdi debian_504_base.vdi
VirtualBox Command Line Management Interface Version 3.0.8_OSE
(C) 2005-2009 Sun Microsystems, Inc.
All rights reserved.

Clone hard disk created in format 'VDI'. UUID: 470c6510-e5f9-4d31-9f0e-fb160e9adfd9
Next, I establish ssh port forwarding on the VM:
VBoxManage setextradata "couch-0.11" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "couch-0.11" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "couch-0.11" \
"VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222
("couch-0.11" refers to the name of the VM, not the disk)

I prefer port forwarding so that I can work with the VM from a local terminal rather than the VM's console. This is mostly for the tighter integration with my normal desktop—especially copy & paste which either doesn't work or is wonky with VMs.

I boot the VM, then ssh into it.

Based on experience last year, I am guessing that I need the following packages installed this time around:
sudo apt-get install \
subversion \
libicu-dev \
libcurl4-gnutls-dev \
libcurl4-gnutls-dev \
erlang \
erlang-dev \
With that, I checkout couchdb from source:
cstrom@debian:~$ mkdir repos
cstrom@debian:~$ cd !$
cd repos
cstrom@debian:~/repos$ svn co couchdb
Ah, it looks like the INSTALL.unix file in there has the required packages listed in it. That would have saved me some time had I thought to check that first. Ah well. It looks as though I did a decent job of identifying the correct packages save for the build-essentials package:
sudo apt-get install build-essential
Hmm... The INSTALL.Unix then says that I ought to be able to run ./configure but there is no such file. Looks as though I still need to bootstrap first:
cstrom@debian:~/repos/couchdb$ ./bootstrap 
./bootstrap: line 54: libtoolize: command not found
Aw nuts.

Searching the Debian packages, I find that I need libtool:
sudo apt-get install libtool
With that:
cstrom@debian:~/repos/couchdb$ ./bootstrap 
./bootstrap: line 57: aclocal: command not found
Aw for cryin' out loud! Clearly build-essential does not mean what it used to mean. Anticipating a bit, I install both automake and autoconf:
cstrom@debian:~/repos/couchdb$ sudo apt-get install automake autoconf
Finally, that seems to do the trick:
cstrom@debian:~/repos/couchdb$ ./bootstrap 
You have bootstrapped Apache CouchDB, time to relax.

Run `./configure' to configure the source before you install.
Sadly that is not the end of the yak shave:
checking for curl-config... /usr/bin/curl-config
checking for curl >= 7.18.0... yes
checking CURL_CFLAGS...
checking CURL_LIBS... -lcurl
checking for erl... /usr/bin/erl
configure: error: The installed Erlang version is less than 5.6.5 (R12B05).
Ugh. I yak shaved the last time I tried to install CouchDB from source. Looks like this time is no different. To stick with Debian stable packages by default, I create an /etc/apt/apt.conf file with:
APT::Default-Release "stable";
I can then add the testing repository to the apt sources.list, which should have a recent enough version of erlang:
deb testing main contrib non-free
With that, a normal update will go against current stable and do nothing:
cstrom@debian:~$ sudo apt-get install erlang
Reading package lists... Done
Building dependency tree
Reading state information... Done
erlang is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
But, specifying the testing sources pulls in the newer erlang package:
cstrom@debian:~$ sudo apt-get install -t testing erlang
Lots of updated installs
That took a really long time over my internet connection so this better work:
config.status: creating utils/Makefile
config.status: creating var/Makefile
config.status: creating config.h
config.status: executing depfiles commands

You have configured Apache CouchDB, time to relax.

Run `make && sudo make install' to install.

Rather than `make install', I prefer checkinstall for easy uninstall:
cstrom@debian:~/repos/couchdb$ sudo checkinstall
sudo: checkinstall: command not found
cstrom@debian:~/repos/couchdb$ sudo apt-get install checkinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 112kB of archives.
After this operation, 557kB of additional disk space will be used.
Get:1 lenny/main checkinstall 1.6.1-8 [112kB]
Fetched 112kB in 1s (84.2kB/s)
Selecting previously deselected package checkinstall.
(Reading database ... 34656 files and directories currently installed.)
Unpacking checkinstall (from .../checkinstall_1.6.1-8_i386.deb) ...
Processing triggers for man-db ...
Setting up checkinstall (1.6.1-8) ...
With that, I can run checkinstall properly:
cstrom@debian:~/repos/couchdb$ sudo checkinstall

checkinstall 1.6.1, Copyright 2002 Felipe Eduardo Sanchez Diaz Duran
This software is released under the GNU GPL.

The package documentation directory ./doc-pak does not exist.
Should I create a default set of package docs? [y]:

Preparing package documentation...OK

Please write a description for the package.
End your description with an empty line or EOF.
>> Edge CouchDB

**** Debian package creation selected ***

*** Warning: The package version "0.12.0a925065
0.12.0a925065" is not a
*** Warning: debian policy compliant one. Please specify an alternate one

Lots and lots of compiling and installing

make install-data-hook
make[3]: Entering directory `/home/cstrom/repos/couchdb'

You have installed Apache CouchDB, time to relax.
make[3]: Leaving directory `/home/cstrom/repos/couchdb'
make[2]: Leaving directory `/home/cstrom/repos/couchdb'
make[1]: Leaving directory `/home/cstrom/repos/couchdb'

======================== Installation successful ==========================

Copying documentation directory...
grep: /var/tmp/tmp.ORkevTfAXB/newfile: No such file or directory

Some of the files created by the installation are inside the build
directory: /home/cstrom/repos/couchdb

You probably don't want them to be included in the package,
especially if they are inside your home directory.
Do you want me to list them? [n]: Should I exclude them from the package? (Saying yes is a good idea) [y]:



Done. The new package has been installed and saved to


You can remove it from your system anytime using:

dpkg -r couchdb

I add a couchdb user:
sudo     adduser --system \
--home /usr/local/var/lib/couchdb \
--no-create-home \
--shell /bin/bash \
--group --gecos \
"CouchDB Administrator" couchdb
I set permissions for the various CouchDB directories:
    chown -R couchdb:couchdb /usr/local/etc/couchdb
chown -R couchdb:couchdb /usr/local/var/lib/couchdb
chown -R couchdb:couchdb /usr/local/var/log/couchdb
chown -R couchdb:couchdb /usr/local/var/run/couchdb
Finally, I run CouchDB:
root@debian:~#     sudo -i -u couchdb couchdb
Apache CouchDB 0.12.0a925065 (LogLevel=info) is starting.
Apache CouchDB has started. Time to relax.
[info] [<0.32.0>] Apache CouchDB has started on
Well, that was a little more painful than I had hoped, but at least I made it. Tomorrow I will ensure that it starts on boot and begin playing with it.

Day #46

1 comment:

  1. For such a task, I would have installed Arch Linux in the virtual machine, then the "couchdb-svn" package from the Arch User Repository. Each time you update it, it gets the new version from SVN and installs it along with all the dependencies.