How to install Apache CouchDB NoSQL database on CentOS 8
How to install Apache CouchDB NoSQL database on CentOS 8
Apache CouchDB is a free, open source document-oriented NoSQL database system written in Erlang. Compared with other relational databases, it does not store data and relationships in tables. It uses JSON to store data, making it more scalable and easier 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 Apache CouchDB NoSQL database on CentOS 8.
prerequisites
- Server running CentOS 8.
- The root password is set on your server.
Install Apache CouchDB
By default, CentOS 8 does not provide Apache CouchDB in the default repository. Therefore, you will need to create an Apache CouchDB repository in the system.
The CouchDB repository depends on the EPEL repository, so you will need to install the EPEL repository in the system. You can use the following command to install:
dnf install epel-release -y
Next, create the Apache CouchDB repository using the following command:
nano /etc/yum.repos.d/apache-couchdb.repo
Add the following line:
[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 when finished. 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 in standalone mode or cluster mode. In this tutorial, we will configure the CouchDB server in single mode. By default, CouchDB listens on the local host, and no administrator account is created during the installation process. Therefore, you will need to create an administrator account for CouchDB. You can create it by editing the file local.ini:
nano /opt/couchdb/etc/local.ini
Set bind-address to 0.0.0.0 to allow access from an external IP address, and set an administrator password internally [admin] The parts are shown below:
[chttpd] port = 5984 bind_address = 0.0.0.0 [admins] admin = password
Save and close the file when finished. Then, start the CouchDB service and enable it to start at startup:
systemctl start couchdbsystemctl enable couchdb
Now you can use the following command to verify the status of the CouchDB service:
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 CouchDB listening port using the following command:
netstat -pnltu | grep 5984
You should 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 enabled in the system. Therefore it is recommended that you disable SELinux in the system.
You can disable SELinux by editing the / etc / selinux / config file:
nano /etc/selinux/config
Find the following line:
SELINUX=enforcing
And, replace it with the following line:
SELINUX=permissive
Save and close the file. Then, restart the system to apply the changes:
Next, you will need to allow port 5984 through firewalld. You can allow it using the following command:
firewall-cmd --zone=public --permanent --add-port=5984/tcpfirewall-cmd --reload
When finished, you can continue to the next step.
Visit CouchDB Web UI
At this point, CouchDB has been installed and configured. Now it’s time to confirm that CouchDB is working properly.
You can check CouchDB using the curl command:
curl http://your-server-ip:5984/
If everything is normal, 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 use the URL http: // your server-ip: 5984 / _utils / to access the CouchDB Web UI. You will be redirected to the CouchDB login page:
Provide your administrator username, password, and click log in Button. You should see the CouchDB dashboard in the following screen:
Use CouchDB database
CouchDB also allows you to create and delete databases using curl commands.
To create a database named testdb in CouchDB, run the following command:
curl -u admin:password -X PUT http://your-server-ip:5984/testdb
You should see the following output:
{"ok":true}
To create a database named userdb in 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 use the curl command to verify the database as follows:
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 on a web browser.
If you want to delete the database testdb, run the following command:
curl -u admin:password -X DELETE http://your-server-ip:5984/testdb
You should get the following output:
{"ok":true}
in conclusion
Congratulations! You have successfully installed Apache CouchDB on CentOS 8. For more information, you can visit Apache. CouchDB Documentation.