Couchdb 1.1.1 on Centos 6

06/11/2011

CouchDBInstalling the lastest version of Couchdb (1.1.1 announced for Halloween) on a centos 6 linux machine is pretty simple. You can install couchDB with yum but the version in the epel (Extra Packages for Enterprise Linux) packages is old : 1.0.2. So these page will describe the installation of couchDB 1.1.1 on CentOS 6 by compiling the couchDB sources.

The following steps work well from a new centos 6 installation.

[fred@calvin ~]$ lsb_release -a
LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 6.0 (Final)
Release:        6.0
Codename:       Final

Refer to the wiki documentation (Installing on RHEL 5) of the couchDB project for a good start.

Preparing the compilation of CouchDB

Installing Erlang. Nothing particular, let’s use yum

[fred@calvin ~]$ sudo yum install erlang

As described in the wiki, install the following libraries

[fred@calvin ~]$ sudo yum install libicu-devel openssl-devel 
curl-devel make gcc erlang js-devel libtool which

Then, the last version of curl can be installed this (classic) way :

[fred@calvin ~]$ wget http://curl.haxx.se/download/curl-7.22.0.tar.gz
[fred@calvin ~]$ tar zxvf curl-7.22.0.tar.gz
[fred@calvin ~]$ cd curl-7.22.0
[fred@calvin ~]$ make
[fred@calvin ~]$ sudo make install

Compile and install CouchDB

Then, let’s download and install couchDB.

[fred@calvin ~]$ wget http://apache.crihan.fr/dist//couchdb/1.1.1/apache-couchdb-1.1.1.tar.gz

In order to avoid the following error :

configure: error: Your SpiderMonkey library is too new.

the good configuration can be (on a 32 bits system)

[fred@calvin ~]$ cd apache-couchdb-1.1.1
[fred@calvin ~]$ ./configure --prefix=/usr/local --enable-js-trunk
[fred@calvin ~]$ make 
[fred@calvin ~]$ sudo make install

If the CentOS system is a 64 bits one, the path to the erlang lib has to be specified :

[fred@calvin ~]$ ./configure --prefix=/usr/local \
> --enable-js-trunk \
> --with-erlang=/usr/lib64/erlang/usr/include

Then, as described in the wiki page, the user couchdb is added :

[fred@calvin ~]$ sudo adduser -r --home /usr/local/var/lib/couchdb -M --shell /bin/bash --comment "CouchDB Administrator" couchdb
[fred@calvin ~]$ sudo chown -R couchdb: /usr/local/var/lib/couchdb /usr/local/var/log/couchdb

Start CouchDB

CouchDB is now ready to start listening requests from localhost. To start the couchDB Service :

[fred@calvin ~]$ sudo /usr/local/etc/rc.d/couchdb start
starting database server couchdb

[fred@calvin ~]$ curl http://localhost:5984
{"couchdb":"Welcome","version":"1.1.1"}

But the connections are impossible on another machine (different from localhost) or in the browser :

[fred@hobbes ~]$ curl http://calvin:5984
curl: (7) couldn't connect to host

In ordrer to make the server listen to the good network interface, the bind address has to be specified. It can be found with the ifconfig command. Get the IP of the eth0 interface, or set the INADDR_ANY address (0.0.0.0) in the configuration file :

[fred@calvin ~]$ sudo /usr/local/etc/rc.d/couchdb stop
Stopping database server couchdb

[fred@calvin ~]$ sudo vim /usr/local/etc/couchdb/local.ini

and set the good value (the eth0 inet address or the 0.0.0.0 address)

bind_address = 0.0.0.0

Then let’s start the server

[fred@calvin ~]$ sudo /usr/local/etc/rc.d/couchdb start
Starting database server couchdb

On the other machine

[fred@hobbes ~]$ curl http://calvin:5984
{"couchdb":"Welcome","version":"1.1.1"}

Time to relax and enjoy !