Introduction:
Apache CouchDB is a database developed for the web, it uses JASON Documents to store the data, access your data with HTTP. You can index, combine and transfer your data with Java Script. Very suitable for all modern web and mobile applications.
Features:
- It is distributed, fault tolerant, and schema free document-oriented database.
- Provides bi-directional conflict detection and resolution.
- Comes with easy to manage web based administration console.
- It is highly available and partition tolerant.
- It comes with fault-tolerant engine that make sure safety of the user data.
Installation:
We will use Ubuntu 15.04 for instillation of Apache Couch DB, ErLang is a necessity for installation for Apache Couch DB, make sure http is install and actively running on the server.
Update the system:
apt-get update
Install tools required to compile Couch DB.
sudo apt-get install --yes build-essential curl git
Install Erlang.
sudo apt-get install -y erlang-dev erlang-manpages erlang-base-hipe erlang-eunit erlang-nox erlang-xmerl erlang-inets
Install other require libraries.
apt-get install -y libmozjs185-dev libicu-dev libcurl4-gnutls-dev libtool
Install python.
sudo apt-get install --yes python-software-properties python g++ make
Download Couch DB.
mkdir couchdb && cd couchdb
wget http://apache.mirrors.tds.net/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz
Extract the package
gunzip /home/unixmen/couchdb/apache-couchdb-1.6.1.tar.gz
tar -xvf /home/unixmen/couchdb/apache-couchdb-1.6.1.tar
Configure Couch DB
cd apache-couchdb-1.6.1
./configure &&make
make install
Create a user ‘couchdb’
useradd -d /var/lib/couchdb couchdb
Assign appropriate permissions:
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/
make couchdb to run as service:
cd /etc/init.d
Update init.d to run couchdb as service, by default.
ln -s /usr/local/etc/init.d/couchdb /etc/init.d
Test /etc/init.d/couchdb command to make sure is is effective or not.
Change the bind address for couch db configuration:
nano /usr/local/etc/couchdb/default.ini && /etc/init.d/couchdb restart
search bind_address and change from 127.0.0.1 to 0.0.0.0
Open the browser and type http://127.0.01:5984
or type
curl http://127.0.0.1:5984/
You will see the welcome message.
{"couchdb":"Welcome",
Have a look on default data base.
curl -X GET http://127.0.0.1:5984/_all_dbs
Sample output:
["_replicator","_users"]
Create a new data base ‘unixmen’.
curl -X PUT http://127.0.0.1:5984/unixmen
Sample output:
{"ok":true}
Let us create one more database using GUI, open browser and type <ip_address_of_couchdb>/_utils
Add data base ”rajneesh’ using gui:
Let’s delete database ‘unixmen’ using cli.
curl -X DELETE http://127.0.0.1:5984/unixmen
Sample output
{"ok":true}
Thats it!
In this tutorials we tested how to setup Apache Couch DB with Ubuntu 15.04 Desktop Version, will try in future to bring some more detailed administration related material for couchdb.
Have fun!