Announcement

How To Install Apache CouchDB on CentOS 7 Server


Apache CouchDB is an open source, document-oriented NoSQL database software that's focused on scalable architecture. Each database is a collection of independent documents, and does not store data and relationships in tables.


In this guide, we will demonstrate the installation and configuration of Apache CouchDB on a CentOS 7 server.


Prerequisites


  • CentOS 7 server with root privileges



Add EPEL Repository

Before installing Apache CouchDB on a CentOS 7 server, we need to add a new EPEL repository (Extra Package for Enterprise Linux).

Add EPEL repository using the following yum command.

yum -y install epel-release


Install Apache CouchDB

Apache CouchDB provides rpm packages for installation on Redhat Linux. So in this step, we will install CouchDB from the Apache repository.

Go to the '/etc/yum.repos.d' directory and create a new repo file 'apache-couchdb.repo' using the vim editor.

cd /etc/yum.repos.d/
vim apache-couchdb.repo

Add the following lines.

[bintray--apache-couchdb-rpm]
 name=bintray--apache-couchdb-rpm
 baseurl=http://apache.bintray.com/couchdb-rpm/el$releasever/$basearch/
 gpgcheck=0
 repo_gpgcheck=0
 enabled=1

Save the change, and exit the editor.

Now install Apache CouchDB using the following command.

yum -y install couchdb

After the installation is complete, start the service and enable it to launch at system boot.

systemctl start couchdb
systemctl enable couchdb

Now check the service.

systemctl status couchdb

And you should get a result similar to the one shown below.

Now check the server port.

netstat -plntu

Apache CouchDB has been successfully installed on the CentOS 7 server, and is running under default port 5984.


Enable Apache CouchDB HTTP server

Apache CouchDB provides the HTTP server for admin access on default port 5984. And has an admin panel Web UI named 'Fauxton'.

Now, we will enable the CouchDB HTTP server for admin panel access. So to begin with, go to the apache couchdb installation directory '/opt/couchdb', and edit the 'default.ini' configuration file under 'etc/' directory.

cd /opt/couchdb
vim etc/default.ini

Now go to the '[chttpd]' configuration line and change the bind_address value with your IP address.

[chttpd]
 port = 5984
 bind_address = 0.0.0.0

Save and exit.

Restart the couchdb service using the following systemctl command.

systemctl restart couchdb

Next, open up web browser and type your server IP address as shown below.

http://your_server_ip:5984/_utils/

And you should get the following Fauxton web UI page.


If you have firewalld running on your server, open the couchdb port 5984 using the firewall-cmd command, as shown below.

firewall-cmd --add-port=5984/tcp --permanent
firewall-cmd --reload


Configure CouchDB

By default, the fresh Apache CouchDB installation has an 'Admin Party'. So anyone who connects to CouchDB server can do anything, including create, delete, add new user etc. To add new admin account for the CouchDB, you will need to create that admin account from the admin panel.

Open up web browser and access the following server IP address on port 5984.

http://your_server_ip:5984/_utils/

Now click on the 'Admin Party' tab, type the admin user and password for couchdb, and then click the 'Create Admin' button.


New admin user for couchdb has been created.

Now, if you want to login to the admin panel Fauxton again, you will have to enter the login details.


Type your admin user and password to get access to the admin panel.


Basic usage Apache CouchDB

Apache CouchDB provides an API for managing the CouchDB system. And we will be using the 'curl' command utility for managing the CouchDB system.

In this step, we will discuss basic management. We will try to create the new database, show database list, delete the database etc using curl command.

To get information about the installed couchdb server, we can use the 'GET' parameter as shown below.

curl -X GET http://localhost:5984/

To create a new database, we need admin privileges. And for this action, we will be using the 'PUT' parameter.

We will create a new database named 'test_db'.

curl -X PUT http://username:password@localhost:5984/test_db

To get information about the database, we must use the 'GET' parameter.

Run the command below to get the database list on the server.

curl -X GET http://username:password@localhost:5984/_all_dbs

And you should get the 'test_db' as part of the retrieved list.

Next, get 'test_db' info using the command below.

curl -X GET http://username:password@localhost:5984/test_db

And the output should contains information related to the database.

For deleting the database on the CouchDB server, you need to use 'DELETE' parameter. Delete the 'test_db' database using the following command.

curl -X DELETE http://username:password@localhost:5984/test_db

Now check again the database list on the CouchDB server.

curl -X GET http://username:password@localhost:5984/_all_dbs

And you'll find that the 'test_db' database is deleted.


Conclusion

The installation and configuration for Apache CouchDB on CentOS 7 has been successful.