Apache CouchDB is a robust and open-source NoSQL database that is designed for scalability and ease of access. Implemented in the concurrency-focused Erlang programming language, CouchDB features a document-oriented architecture, utilizing JSON to store data, JavaScript for querying through MapReduce, and HTTP for its RESTful API. It employs a multi-version concurrency control method, meaning write operations do not lock the database files. This makes it a solid choice for applications on mobile devices that require replication and synchronization capabilities.
In this guide, we’ll walk through the installation process of CouchDB on an Ubuntu 18.04 LTS (Bionic Beaver) server.
Requirements
- Ubuntu 18.04 server environment.
- Non-root user account with sudo permissions.
Install Apache
Prior to setting up CouchDB, you need the Apache web server, which can be installed using the command below:
sudo apt-get install apache2 -y
Once installation is complete, start the Apache server and enable it to boot at startup using these commands:
sudo systemctl start apache2 sudo systemctl enable apache2
Install CouchDB
Out of the box, CouchDB is not included in Ubuntu’s 18.04 package repositories; thus, adding the official CouchDB repository is necessary. Begin by appending the repository with this command:
echo "deb https://apache.bintray.com/couchdb-deb xenial main" | sudo tee -a /etc/apt/sources.list
Next, authenticate the added repository:
curl -L https://couchdb.apache.org/repo/bintray-pubkey.asc | sudo apt-key add -
Afterwards, update your package lists and proceed with the installation of CouchDB:
sudo apt-get update -y sudo apt-get install couchdb -y
During installation, a series of configuration prompts will appear, as shown:
Upon completion, start CouchDB and configure it to run at startup:
sudo systemctl start couchdb sudo systemctl enable couchdb
To verify that CouchDB is running, execute:
sudo systemctl status couchdb
Output:
? couchdb.service - Apache CouchDB Loaded: loaded (/lib/systemd/system/couchdb.service; enabled; vendor preset: Active: active (running) since Sun 2018-06-10 20:22:25 IST; 45s ago Main PID: 3092 (beam) CGroup: /system.slice/couchdb.service ??3092 /opt/couchdb/bin/../erts-7.3/bin/beam -K true -A 16 -Bd -- -ro ??3119 /opt/couchdb/bin/../erts-7.3/bin/epmd -daemon ??3145 sh -s disksup ??3149 /opt/couchdb/bin/../lib/os_mon-2.4/priv/bin/memsup ??3150 /opt/couchdb/bin/../lib/os_mon-2.4/priv/bin/cpu_sup Jun 10 20:22:25 Node1 systemd[1]: Started Apache CouchDB. Jun 10 20:23:01 Node1 systemd[1]: Started Apache CouchDB. Jun 10 20:23:04 Node1 systemd[1]: Started Apache CouchDB.
Access CouchDB Web Interface
With CouchDB up and running, it listens on port 5984, accessible via the URL http://your-server-ip:5984/_utils/. Upon visiting, you’ll be directed to this screen:
Here, enter your admin credentials to login, leading you to the management interface:
Frequently Asked Questions (FAQ)
1. Can CouchDB be used on mobile devices?
Yes, CouchDB is highly suitable for mobile devices due to its replication and synchronization features.
2. Do I need Apache web server for CouchDB?
While CouchDB itself doesn’t require Apache, the tutorial includes setting up an Apache server to provide a complete setup process on a new server.
3. Is the CouchDB interface secured?
The default CouchDB setup does not include SSL encryption for its web interface. Consider setting up a reverse proxy with SSL between clients and CouchDB for added security.
4. What is the default port CouchDB listens on?
CouchDB listens on port 5984 by default.
5. Can I upgrade my CouchDB installation from an older version?
Yes, but it’s recommended to backup your data and consult the official CouchDB documentation for version-specific upgrade steps.