Linux

How to Install the NoSQL Apache CouchDB Database on CentOS 8

How to Install the NoSQL Apache CouchDB Database on CentOS 8

Apache CouchDB is a NoSQL database system, free open source document oriented written in Erlang. Compared to other relational databases, it does not store data and relationships in tables. Using JSON to store data which makes it more scalable and easy to model data. It also supports a quiet HTTP API that allows you to create, edit and delete database documents.

In this tutorial, we will explain how to install the NoSQL Apache CouchDB database on CentOS 8.

Precondition

  • Server running CentOS 8.
  • The root password is set on your server.

Install Apache CouchDB

By default, Apache CouchDB is not available in the CentOS 8 default repository. So, you need to create an Apache CouchDB repo on your system.

The CouchDB repository is reliable in the EPEL repository, so you must install the EPEL repo on your system. You can install it with the following command:

dnf install epel-release -y

Next, create an Apache CouchDB repo using the command below:

nano /etc/yum.repos.d/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 and close the file after you finish. Then, install Apache CouchDB using the following command:

dnf install couchdb -y

After the installation is successfully completed, you can proceed to the next step.

Configure CouchDB

You can configure CouchDB as standalone mode or in clustered mode. In this tutorial, we will configure the CouchDB server in single mode. By default, CouchDB listens on localhost and no admin account is created during installation. So you have to create an admin account for CouchDB. You can create one by editing the local.ini file:

nano /opt/couchdb/etc/local.ini

Set the bind-address to 0.0.0.0 to allow access from an external IP address and also set the admin password in the [admin] section as shown below:

[chttpd]
port = 5984
bind_address = 0.0.0.0  

[admins]
admin = password

Save and close the file after you finish. Then, start the CouchDB service and activate it to start at boot:

systemctl start couchdb
systemctl enable couchdb

You can now verify the status of the CouchDB service using the following command:

systemctl status couchdb

You should get the following output:

? couchdb.service - Apache CouchDB
   Loaded: loaded (/usr/lib/systemd/system/couchdb.service; disabled; vendor preset: disabled)
   Active: active (running) since Sat 2020-04-11 07:40:47 EDT; 35s ago
 Main PID: 11992 (beam.smp)
    Tasks: 43 (limit: 26213)
   Memory: 36.4M
   CGroup: /system.slice/couchdb.service
           ??11992 /opt/couchdb/bin/../erts-9.3.3.14/bin/beam.smp -K true -A 16 -Bd -- -root /opt/couchdb/bin/.. -progname couchdb -- -home /o>
           ??12004 /opt/couchdb/bin/../erts-9.3.3.14/bin/epmd -daemon
           ??12023 erl_child_setup 1024
           ??12045 sh -s disksup
           ??12047 /opt/couchdb/bin/../lib/os_mon-2.4.4/priv/bin/memsup
           ??12048 /opt/couchdb/bin/../lib/os_mon-2.4.4/priv/bin/cpu_sup

Apr 11 07:40:47 centos8 systemd[1]: Started Apache CouchDB.

You can also check the listening port of CouchDB with the following command:

netstat -pnltu | grep 5984

You will see the following output:

tcp     0   0 0.0.0.0:5984     0.0.0.0:*      LISTEN      11992/beam.smp

Configure SELinux and Firewall

By default, SELinux is activated on your system. So it is recommended to disable SELinux on your system.

You can disable SELinux by editing / etc / selinux / config file:

nano /etc/selinux/config

Find the following lines:

SELINUX=enforcing

And, replace with the following line:

SELINUX=permissive

Save and close the file. Then, restart your system to apply changes:

Next, you must allow port 5984 through firewalld. You can allow it with the following command:

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

After completion, you can proceed to the next step.

Access the CouchDB Web UI

At this point, CouchDB is installed and configured. It’s time to confirm that CouchDB is functioning or not.

You can use the curl command to check CouchDB:

curl http://your-server-ip:5984/

If everything is fine, you should get the following output:

{"couchdb":"Welcome","version":"3.0.0","git_sha":"03a77db6c","uuid":"d0406ea8f0b1a3f18020ec90e627ae35","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}

You can also access the CouchDB UI web using the URL http: // your-server-ip: 5984 / _utils /. You will be directed to the CouchDB login page:

1

Provide the admin username, password, and click the Enter button. You will see the CouchDB dashboard in the following screen:

2

Works with the CouchDB Database

CouchDB also allows you to create and delete databases using the curl command.

To create a database named testdb on CouchDB, run the following command:

curl -u admin:password -X PUT http://your-server-ip:5984/testdb

You will see the following output:

{"ok":true}

To create a database named userdb on CouchDB, run the following command:

curl -u admin:password -X PUT http://your-server-ip:5984/userdb

You should get the following output:

{"ok":true}

You can also verify the database using the curl command as shown below:

curl -u admin:password -X GET http://your-server-ip:5984/testdb

You should get the following output:

{"db_name":"testdb","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"}

You can also refresh the CouchDB dashboard to view the database in your web browser.

3

If you want to delete the testdb database, run the following command:

curl -u admin:password -X DELETE http://your-server-ip:5984/testdb

You should get the following output:

{"ok":true}

Congratulations! You have successfully installed Apache CouchDB on CentOS 8. For more information, you can visit the Apache CouchDB Documentation.

Related posts

How to Install the SNMP Cacti Monitoring Tool on Debian 10

Linux

How to Change Hostname on Ubuntu 20.04

Linux

How to Destroy / Erase Data Safely on Hard Drive with Damaged on Linux

Linux

How to Install Tomcat 9 on Ubuntu 20.04

Linux

How to Install Apache on Ubuntu 20.04

Linux

How to Install Docker on Ubuntu 20.04

Linux

How to Set Up WireGuard VPN Server and Client on Ubuntu 20.04

Linux

How to create files in Python and more

Linux

How to install Lightworks on Ubuntu

Linux