Hop in as we explain how to install and setup CouchDB on CentOS 8.
What do you need?
Here are the prerequisites before plodding along:
- An instance of CentOS 8 with sudo user already configured.
- Access to your CentOS 8 via SSH or GUI.
Alrighty! Let’s roll our sleeves!
Install CouchDB on CentOS
Step 1: Enable the CouchDB repository on the local system
Right off the bat, access your instance of CentOS 8. We are first going to append the CouchDB repository to the local system first before installing it.
So, create a repository file in the /etc/yum.repos.d/ directory as shown.
$ sudo vim /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo
Add the lines shown below.
Save and exit from the repository file. With the repository in the palace, we shall proceed and install CouchDB.
Step 2: Install CouchDB on your CentOS 8 system
The installation of CouchDB is quite simple and straightforward. Just invoke the command:
$ sudo dnf install couchdb
Press ‘y’ to proceed when prompted.
Upon completion of CouchDB installation, ensure enable CouchDB as follows.
$ sudo systemctl enable couchdb
Once enabled on boot time, start the service.
$ sudo systemctl start couchdb
A few additional tweaks are required to properly configure CouchDB. Let’s explore.
Step 3: Setting up CouchDB
According to the official documentation, CouchDB can exist in either a single-node or a cluster setup. Here, we will demonstrate the configuration of CouchDB in a single-node setup.
On the command-line, we will define the admin user and the corresponding password.
To accomplish this, head over and edit the /opt/couchdb/etc/local.ini file.
$ sudo vim /opt/couchdb/etc/local.ini
Under the section [admins] section uncomment the line beginning with admin. By default, the password is set to mysecretpassword.
Ensure that you set a robust password to avert brute force attacks that might compromise your system.
Save the file. Then proceed and restart CouchDB.
$ sudo systemctl restart couchdb
Lastly, we need to create system-wide databases. These are:
Use the curl command and invoke the commands below. Be sure to replace admin_user and admin_password with your own values that you specified in the /opt/couchdb/etc/local.ini file.
$ curl -u admin_user:admin_password -X PUT http://127.0.0.1:5984/_users
$ curl -u admin_user:admin_password -X PUT http://127.0.0.1:5984/_replicator
$ curl -u admin_user:admin_password -X PUT http://127.0.0.1:5984/_global_changes
Step 4: Verify the installation & setup of CouchDB
We are all caught up with the configurations. There are various ways of verifying that our installation was a success. On command-line execute the following curl command.
$ curl http://127.0.0.1:5984/
Some JSON information regarding the CouchDB instance will be printed on your terminal as shown.
Alternatively, you can use the URL below on your browser to get similar JSON information in a more organized orientation.
Access CouchDB using a browser
Finally, to log in to your instance, browse the URL below
On the login page, key in the admin username and password defined previously.
Then hit the ‘Log In’ button.
On the dashboard, the databases you created in the previous step will be displayed.
Awesome! This confirms successful CouchDB installation. If you run into any problem, comment below for help.
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.