On this article we will discuss how to install Apache CouchDB on CentOS 8 operating system and access it through the its dashboard.
Introduction
The Increasing human activity will correlate with the more data generated. The use of social media, shopping transactions, uploading video tutorials or meeting files that are distributed further adds to the data generated. The use of relational databases, which have dominated for decades, is felt to be heavy enough to accommodate the exponential data generated at this time. There are currently many NoSQL databases available and in use, including: MongoDB, Redis, CouchDB which are usually initiated by the open source community. CouchDB as a NoSQL database has its own fan base and is used in applications that running a business. On this occasion, we will discuss how to install CouchDB on CentOS 8.
Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang. CouchDB was first released in 2005 by Damien Katz, a former Lotus Notes developer at IBM, and later became an Apache Software Foundation project in 2008. The latest stabel version of CouchDB is version 3.1.1. The Couch is an acronym for cluster of unreliable commodity hardware.
Apache CouchDB on CentOS 8 Installation
Before we are going to start the installation, we need tp prepare our system environment is supports for the Apache CouchDB installation process. The installation process will consist of several stages, namely:
- Prerequisite
- Install the EPEL Repository CentOS 8
- Enable the CouchDB Repository
- Install CouchDB on CentOS 8
- Configure of CouchDB on CentOS 8
- Accessing CouchDB
- Trying CouchDB
Prerequisite
Before we are going to install Apache Kafka on CentOS 8, we have to prepare the environment where the CouchDB will be installed.
- CentOS 8 System
- root or ordinary account with sudo privilege
- Sufficient disk space
Install the EPEL Repository CentOS 8
EPEL (Extra Packages for Enterprise Linux) is repository project from Fedora team that provides an easy access to install packages for commonly used software. EPEL project is not a part of RHEL/CentOS but it was designed for major Linux distributions. EPEL provides lots of open source packages like networking tools, sysadmin tools, programming, monitoring and other tools. The epel repository installation by submitting command line below :
[ramans@otodiginet ~]$ sudo dnf install epel-release -y

Enable the CouchDB Repository
Next, we have to create the file /etc/yum.repos.d/apache-couchdb.repo
for enabling CouchDB repository, this step can be done by submitting command line below :
[ramans@otodiginet ~]$ sudo vi /etc/yum.repos.d/apache-couchdb.repo
The conten of this file is as below :
[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

Install CouchDB on CentOS 8
After repository file has been created, then we submit the command line for installing CouchDB. This job can be done with dnf install couchdb -y
commad line.
1. Submit command line dnf install couchdb -y
[ramans@otodiginet ~]$ sudo dnf install couchdb -y
[ramans@otodiginet ~]$ sudo dnf install couchdb -y bintray--apache-couchdb-rpm 26 kB/s | 94 kB 00:03 Last metadata expiration check: 0:00:01 ago on Fri 25 Sep 2020 10:00:02 AM PDT. Dependencies resolved. Package Arch Version Repository Size Installing: couchdb x86_64 3.1.1-1.el8 bintray--apache-couchdb-rpm 24 M Transaction Summary Install 1 Package Total download size: 24 M Installed size: 51 M Downloading Packages: couchdb-3.1.1-1.el8.x86_64.rpm 881 kB/s | 24 MB 00:27 Total 881 kB/s | 24 MB 00:27 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: couchdb-3.1.1-1.el8.x86_64 1/1 Installing : couchdb-3.1.1-1.el8.x86_64 1/1 Running scriptlet: couchdb-3.1.1-1.el8.x86_64 1/1 Verifying : couchdb-3.1.1-1.el8.x86_64 1/1 Installed products updated. Installed: couchdb-3.1.1-1.el8.x86_64 Complete!

2. Edit /opt/couchdb/etc/local.ini
file
The next step is configuring the CouchDB to enable it can be accessed from other hosts. The configuration file is located on /opt/couchdb/etc/local.ini
. The CouchDB is using port 5984 as default. If we need to change this port it is

/opt/couchdb/etc/local.ini
file3. Starting and Enabling CouchDB services. The next step is starting CouchDB service and check it status.
[ramans@otodiginet ~]$ sudo systemctl start couchdb [ramans@otodiginet ~]$ sudo systemctl enable couchdb Created symlink /etc/systemd/system/multi-user.target.wants/couchdb.service → /usr/lib/systemd/system/couchdb.service.
4. Checking CouchDB status
[ramans@otodiginet ~]$ sudo systemctl status couchdb ● couchdb.service - Apache CouchDB Loaded: loaded (/usr/lib/systemd/system/couchdb.service; enabled; vendor preset: disabl> Active: active (running) since Fri 2020-09-25 10:20:45 PDT; 13s ago Main PID: 4481 (beam.smp) Tasks: 40 (limit: 49614) Memory: 48.7M CGroup: /system.slice/couchdb.service ├─4481 /opt/couchdb/bin/../erts-9.3.3.14/bin/beam.smp -K true -A 16 -Bd -- -roo> ├─4499 /opt/couchdb/bin/../erts-9.3.3.14/bin/epmd -daemon └─4518 erl_child_setup 65536 Sep 25 10:20:45 otodiginet systemd[1]: Started Apache CouchDB.

As additional step, we will verify if the CouchDB service is listening on port 5984. This task can be done by submitting command line below :
[ramans@otodiginet ~]$ netstat -pnltu | grep 5984 (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:5984 0.0.0.0:* LISTEN

By default, the SELINUX is configured on our syste, for the time being we have to disable it firest. We will update it by changing the its value on /etc/selinux/config
file.
[ramans@otodiginet ~]$ sudo vi /etc/selinux/config
Find the entity ‘SELINUX=enforcing’ and change it to be ‘SELINUX=permisif’.
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=permissive # SELINUXTYPE= can take one of these three values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
If we are using firewall on our server, we must also allow this port tobe accessible.
[ramans@otodiginet ~]$ sudo firewall-cmd --zone=public --permanent --add-port=5984/tcp success [ramans@otodiginet ~]$ sudo firewall-cmd --reload success

Accessing CouchDB
To verify if CouchDB is working normal, we will test it by using curl
command line to query the CoucDB status. As the information, our system has IP Address 192.168.59.128
or domain name otodiginet
.
ramans@otodiginet ~]$ curl http://192.168.59.128:5984/ {"couchdb":"Welcome","version":"3.1.1","git_sha":"ce596c65d","uuid":"7b3302ce32446079cad904f4bf12998a","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

We also could test the CouchDb by hitting its dasboard via web browser, where the url is located on http://coucdb_server_IP:5984/_utils/
.

So far, our installation is on the track where the services are running properly.
Using CouchDB
As we know, if our CouchDB version is 3.1.1. It is the latest version. On this section we will try to create database, show database and delete database using command line either dashboard.
1. CouchDB dashboard at the first time

2. Creating Database
By using curl
request we will create database, called rapik_db with command line below :
[ramans@otodiginet ~]$ curl -u admin:mysecretpassword -X PUT http://otodiginet:5984/rapik_db {"ok":true}
Query the database, with command line below :
[ramans@otodiginet ~]$ curl -u admin:mysecretpassword -X GET http://otodiginet:5984/rapik_db
the output will be as follow :
{"db_name":"rapik_db","purge_seq":"0-g1AAAABXeJzLYWBgYMpgTmEQTM4vTc5ISXIwNDLXMwBCwxyQVB4LkGRoAFL_gSArkQGP2kSGpHqIoiwAtOgYRA","update_seq":"0-g1AAAABXeJzLYWBgYMpgTmEQTM4vTc5ISXIwNDLXMwBCwxyQVB4LkGRoAFL_gSArkQGP2kSGpHqIoiwAtOgYRA","sizes":{"file":16700,"external":0,"active":0},"props":{},"doc_del_count":0,"doc_count":0,"disk_format_version":8,"compact_running":false,"cluster":{"q":2,"n":1,"w":1,"r":1},"instance_start_time":"0"}


3. Test Deleting Databse
- Create new database called as testdelete_db:
curl -u admin:mysecretpassword -X PUT http://otodiginet:5984/testdelete_db
- Show the new database created:
curl -u admin:mysecretpassword -X GET http://otodiginet:5984/testdelete_db
or via dashboard below :

3. Delete database : curl -u admin:mysecretpassword -X DELETE http://otodiginet:5984/testdelete_db

Conclusion
So far, we have tried to install CouchDB on CentOS 8 and successfully done. And also we have tried to create, query and delete database on CouchDB. As NoSQL database, we could use the JSON for interacting with CouchDB. Just drop your comments or insigth about this article. Have a nice day, stay at home and stay save.
One thought on “How to Install Apache CouchDB On CentOS 8”