How to Install CouchDB on CentOS 8

Posted 

3 min read

Apache CouchDB is a free and open-source NoSQL database developed by the Apache Software Foundation. It can be used as a single-node or clustered database.

CouchDB server stores its data in named databases, which contains documents with JSON structure. Each document consists of a number of fields and attachments. Fields can include text, numbers, lists, booleans, more. It includes a RESTful HTTP API that allows you to read, create, edit, and delete database documents.

In this article, we will cover the installation of CouchDB on CentOS 8.

Enabling CouchDB Repository

The easiest way to install CouchDB on CentOS 8 is to enable the vendor repository and install the binary packages.

Open your editor of choice as root or user with sudo privileges and create the CouchDB repository file:

sudo nano /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo

Paste the following content to the file:

/etc/yum.repos.d/bintray-apache-couchdb-rpm.repo
[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 file and close the editor.

Installing CouchDB on CentOS

Install the CouchDB packages by running the following command:

sudo dnf install couchdb

Once the installation is completed, enable and start the CouchDB service:

sudo systemctl enable --now couchdb

Configuring CouchDB

CouchDB can be set up in a single-node or a clustered mode. In this example, we'll deploy the server in single-node configuration. Check the official documentation about how to set up CouchDB in clustered mode.

You can configure CouchDB using the Fauxton, at http://127.0.0.1:5984/_utils#setup or from the command-line. The Setup Wizard will guide you through the mode selection and admin creation.

We'll create the admin user and the databases from the command-line.

Apache CouchDB data and configuration files are stored in the /opt/couchdb directory. To create an admin account, open the local.ini file and add a line under the [admins] section in the format username = password.

sudo nano /opt/couchdb/etc/local.ini
/opt/couchdb/etc/local.ini
[admins]
admin = mysecretpassword

Restart the CouchDB service to change the password to a hash:

sudo systemctl restart couchdb

You can use the same format to add multiple admin accounts. Always restart the CouchDB service after adding a new account.

Use curl to create the system databases _users, _replicator, and _global_changes:

curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_userscurl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_replicatorcurl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_global_changes

Each command should return the following:

{"ok":true}

Verifying CouchDB Installation

The CouchDB server is running at localhost:5984. To verify whether the installation was successful and the service is running, run the following curl command that will print information about the CouchDB database in JSON format:

curl http://127.0.0.1:5984/

For clarity, the output below is formatted.

{ 
   "couchdb":"Welcome",
   "version":"2.3.1",
   "git_sha":"c298091a4",
   "uuid":"5e3878666b1077eb9d4a7ba7b06c251b",
   "features":[ 
      "pluggable-storage-engines",
      "scheduler"
   ],
   "vendor":{ 
      "name":"The Apache Software Foundation"
   }
}

If you prefer GUI, you can access the CouchDB web-based interface, Fauxton at:

http://127.0.0.1:5984/_utils/

Conclusion

We've shown you how to install CouchDB CentOS 8. Your next step could be to visit the Apache CouchDB Documentation and find more information on this topic.

Feel free to leave a comment if you have any questions.