Thursday, 9 April 2015

Getting started with CouchDB-Part 1

Getting started with CouchDB-Part 1
Installation and Configuration

In this series of simple tutorials, I'm going to show you how you can get started with a popular and upcoming NoSQL database called CouchDB.

Part 1: Installation and Configuration
Part 2: Running basic commands
Part 3: Clustering

Introducing CouchDB
A few interesting facts that you should know about CouchDB before we begin:
  • CouchDB is a JSON document-oriented database written in Erlang.
  • It is a highly concurrent database designed to be easily replicable, scale horizontally across numerous devices and be fault tolerant.
  • It is an open source Apache foundation project.
  • It allows applications to store JSON documents via its RESTful interface.
  • It makes use of map/reduce to index and query the database.
  • Follows ACID Semantics.
  • Eventual Consistent.
  • Provides Mobile access.

Setup for this guide:
For this set of tutorials, I'll be running CouchDB on a set of CentOS 6.5 64 Bit Virtual Machines. You can run CouchDB off physical commodity-based hardware as well.

  • OS: CentOS 6.5 64 bit

CouchDB can be installed both via packages as well as from source. Installation from packages is quite simple in case you are using a Debian/ ubuntu system. All you need to do is run the following command on the terminal:

# sudo apt-get install couchdb

Notice that the packages in the repositories are not always the latest version. So in this case we will be installing CouchDB from source.

First off, install some pre-requisite software. This will be required to build and install CouchDB from its source.

yum install libicu-devel curl-devel ncurses-devel libtool libxslt fop java-1.6.0-openjdk java-1.6.0-openjdk-devel unixODBC unixODBC-devel openssl-devel

Next, we install Erlang. CentOS unfortunately does not provide any official packages for Erlang, so you will have to build it from source.

First, go to and download the latest source code.

# wget

Unpack the archive 

# tar -zxvf otp_src_17.4.tar.gz

CD into the new directory and run the following command:

# cd otp_src_17.4

# ./configure

Make sure you dont get any gcc compiler-based errors here. Next, run the make command:

# make 

And finally the make install

# make install

If all goes well, your CentOS system should have Erlang successfully installed on it by now. To test whether it did go well, just type in "erl" to enter the Erlang shell prompt. You should see a similar output as shown.

# erl

Next, we need to install something called as SpiderMoney JavaScript Engine.
Mozilla's SpiderMoney JavaScript Engine is required by CouchDB in order to compile successfully.

CouchDB requires Mozilla's SpiderMoney version 1.8.5, which you can download from their FTP:

# wget

unpack the archive:

# tar -zxvf js185-1.0.0.tar.gz

CD into the following directory and run the following command:

# cd js-1.8.5/js/src/

# ./configure

Next, run the make command

# make

And finally the make install:

# make install

With our pre-requisites met, we can now finally go ahead and install CouchDB on our host. First off, downlaod the latest source of CouchDB:

# wget

Unpack the archive using the following command:

# tar -zxvf apache-couchdb-1.6.1.tar.gz

Follow the same 3-step build and install process as we  performed for Erlang and SpiderMonkey. CD into the new directory and run the configure command:

# cd apache-couchdb-1.6.1

# ./configure

Next, run the make command

# make

And finally the make install:

# make install

Create a user for CouchDB to use:

# adduser --no-create-home couchdb

Change the owner on the following files to the newly created user:

# chown -R couchdb:couchdb \
/usr/local/var/lib/couchdb \
/usr/local/var/log/couchdb \

Create a symlink for the couchdb init script to /etc/init.d:

# ln -sf /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb

Add couchdb's init script in chkconfig and enable it so that it starts CouchDB on boot:

# chkconfig --add couchdb

# chkconfig couchdb on

By default, CouchDB can be accessed only from the server it is installed on itself. If you'd like to access it from the web, you'll have to edit the following configuration file:

# vi /usr/local/etc/couchdb/local.ini 

Should you need to access couchdb from the web, in the [httpd] section, look for a setting called bind_address and change it to - this will make CouchDB bind all available addresses. You can optionally change the port number as well if you wish to do so.

port = 5984 
bind_address =

Once done, start the couchdb service

# service couchdb start

A simple test to check whether CouchDB is indeed running or not, you can simply run couchdb on the command line. it will show you the following output: "Apache CouchDB is running, time to relax". 

To additionally verify its working, simply query the CouchDB port using curl:

# curl http://localhost:5984

You should see a similar output:
   "vendor":{"name":"The Apache Software Foundation","version":"1.6.1"}

You can pass your Server's IP address as well to test the connectivity:

# curl

With this we come to an end of the installation and configuration process. In PART 2, we will be looking at how to run few simple commands in CouchDB, so stay tuned for a lot more coming your way soon!!



Albert Barkley said...

I have bought VPS server to host my dissertation writing services based websites. I believe that your post will help me to install Centos operating system properly.

Harrison Reynolds said...

Your article will help each reader how to install Centos operating system properly.All the procedure is understandable.
web application development company

Shawn Jasper said...

Thank you very much for sharing this information that i have not read before Web hosting in Lahore

tech howitzer said...

thanks a lot for sharing such insightful posts , keep sharing such posts in future too
linux training in chennai | best linux training institute in chennai

tech howitzer said...

Nice stuff thanks for sharing , keep updating red hat linux training in chennai | VMware training in chennai | linux training in chennai thanks again

Meiqing Xu said...

nmd shoes
cveland cavaliers jerseys
prada outlet
christian louboutin shoes
polo ralph lauren
hermes birkin
nike free run flyknit
adidas super color
pandora charms
michael kors handbags

Post a Comment