Jun 5, 2023 5 min read

Discover How to Easily Install CouchDB on CentOS 7

Install CouchDB on CentOS 7 with our step-by-step tutorial. It is a free and open-source NoSQL database to store and manage data.

Easily Install CouchDB on CentOS 7
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install CouchDB on CentOS 7, let's briefly understand – What is CouchDB?

CouchDB is a popular NoSQL database that stores and manages data using a document-based approach. It offers a flexible data model, allowing for easy adaptation to changing requirements. With built-in replication and synchronization support, CouchDB ensures data availability and consistency across devices and locations.

Its scalable architecture enables efficient handling of large datasets, while offline capabilities enable seamless data access and synchronization even without an internet connection. With fault-tolerant design and high availability features, CouchDB ensures continuous data accessibility, reducing downtime and data loss risks. Overall, CouchDB is a powerful and versatile database solution for modern applications.

This tutorial explains how to install the most recent version of CouchDB on Ubuntu CentOS 7. Installing CouchDB on Ubuntu is straightforward.

Advantages of CouchDB

  1. Flexible Data Model: CouchDB's document-based approach allows for dynamic and schema-less data, accommodating changing requirements.
  2. Replication and Sync: Built-in support for replication and synchronization ensures data availability and consistency across multiple devices and locations.
  3. Scalability: CouchDB's distributed architecture enables horizontal scaling, allowing for high-performance handling of large amounts of data.
  4. Offline Support: CouchDB's built-in offline capabilities enable seamless data access and synchronization even when disconnected from the network.
  5. High Availability: CouchDB's fault-tolerant design and support for multi-node clusters ensure continuous availability of data, minimizing downtime and data loss.

Prerequisites to Install CouchDB on CentOS 7

You must be logged in as a user with sudo privileges in order to install new packages on your CentOS system.

Enabling CouchDB Repository

The EPEL repository is necessary for the CouchDB repository to function. If your system does not already have the EPEL repository enabled, use the following command:

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
💡
If you don't have dnf installed then install it via sudo yum install dnf 

After that, open your preferred editor and create the CouchDB repository file as follows:

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

Type the following text into the document:

[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

Close the editor after saving the document.

Installing CouchDB on CentOS

Using the following command, you can now install the CouchDB packages when the repository has been enabled:

For installing CouchDB:
1. Add Repository:

sudo yum-config-manager --disable bintray--apache-couchdb-rpm
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://couchdb.apache.org/repo/couchdb.repo

2. Install CouchDB:

sudo yum install -y couchdb

After installation is finished, activate and launch the CouchDB service:

By default, CouchDB listens solely on localhost, and no admin account is made.

The /opt/couchdb directory contains the configuration files and data for Apache CouchDB. Open the local.ini file and add a line to the [admins] section in the format username = password to create an admin account.

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

You can also change the bind address if you want to access it on public IP:

[chttpd]
;port = 5984
bind_address = 0.0.0.0

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

sudo systemctl restart couchdb

Multiple admin accounts can be added using the same format. After adding a new account, the CouchDB service needs to be restarted.

Create the following system databases using curl: _users, _replicator, and _global_changes.

curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_users
curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_replicator
curl -u ADMINUSER:PASS -X PUT http://127.0.0.1:5984/_global_changes

Change ADMINUSER and PASS with yours.

The following output should be returned for each command:

Output

{"ok":true}

Verifying CouchDB Installation

Use the curl command below to print the data from the CouchDB database in JSON format to check if the installation was successful:

curl http://127.0.0.1:5984/

The output below has been formatted for clarity.

Output

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

You can access the CouchDB web-based interface, Fauxton, if you prefer a GUI, at:

http://127.0.0.1:5984/_utils/
CouchDB GUI

FAQs Install CouchDB on CentOS 7

Where is the CouchDB configuration file located?

The CouchDB configuration file is located at /opt/couchdb/etc/local.ini.

How do I access the CouchDB web interface?

After installing CouchDB, you can access the web interface by opening your browser and navigating to http://localhost:5984/_utils/. Remember to replace "localhost" with the appropriate IP address or hostname if accessing it remotely.

How can I secure my CouchDB installation?

To secure CouchDB, you can modify the CouchDB configuration file (local.ini) and set up authentication, enable SSL/TLS encryption, and configure firewall rules to restrict access to the database.

How can I create a new database in CouchDB?

To create a new database in CouchDB, you can use the CouchDB web interface or send an HTTP request using tools like cURL. For example, using cURL: curl -X PUT http://localhost:5984/mydatabase

How do I enable CORS (Cross-Origin Resource Sharing) in CouchDB?

To enable CORS in CouchDB, you need to modify the CouchDB configuration file (local.ini) and add the appropriate configuration settings under the [httpd] section.

How can I back up and restore CouchDB databases?

CouchDB provides a built-in backup and restore functionality called "replication." You can use the CouchDB replication feature to create backups by replicating the database to another CouchDB instance or a different location.

Can I use CouchDB with programming languages like Python or Node.js?

Yes, CouchDB provides HTTP-based APIs that allow you to interact with the database using various programming languages. You can use libraries or frameworks specific to your preferred programming language, such as couchdb-python for Python or nano for Node.js, to interact with CouchDB easily.

How can I upgrade CouchDB to a newer version on CentOS 7?

To upgrade CouchDB on CentOS 7, you need to follow the steps provided by the CouchDB documentation for the specific version you wish to upgrade to. Typically, it involves downloading the new version and replacing the existing CouchDB installation.

Conclusion

You have successfully learned how to install CouchDB on CentOS 7. Visit the Apache CouchDB Documentation to learn more about this topic.

If you have any queries, post them down below, and we'll be glad to answer them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.