Discover how to install CouchDB Server on CentOS 8 with our detailed guide. Follow step-by-step instructions to set up CouchDB for efficient data storage and management on your Linux system. #centlinux #linux #couchdb
Table of Contents
What is Apache CouchDB?
Apache CouchDB is an open-source NoSQL database management system that emphasizes ease of use, scalability, and flexibility. Here are key points about Apache CouchDB:
- Document-Oriented: CouchDB stores data in JSON-like documents, making it flexible for storing semi-structured and unstructured data.
- Distributed Architecture: Designed for distributed computing environments, CouchDB supports multi-master replication. This means multiple databases can synchronize changes bidirectionally.
- ACID Compliance: CouchDB ensures data integrity and consistency through ACID (Atomicity, Consistency, Isolation, Durability) properties for individual documents.
- HTTP Protocol: CouchDB uses HTTP and JSON for its API, allowing easy integration with web applications and straightforward data manipulation using standard HTTP methods (GET, PUT, POST, DELETE).
- MapReduce Views: CouchDB allows developers to create views using JavaScript for querying and aggregating data. Views are built using MapReduce functions and can be indexed for faster query execution.
- Conflict Resolution: Provides built-in conflict resolution mechanisms to handle concurrent updates to the same document across distributed databases.
- Fault Tolerance and Scalability: Designed to be fault-tolerant and scalable, CouchDB can handle large volumes of data and concurrent users.
- Cross-Platform: Apache CouchDB is cross-platform and runs on various operating systems, including Linux, macOS, and Windows.
- Use Cases: CouchDB is suitable for applications requiring offline-first capabilities, decentralized synchronization, and flexible data modeling. It is used in content management systems, mobile apps, IoT (Internet of Things) applications, and more.
Apache CouchDB is maintained by the Apache Software Foundation and is available under the Apache License, making it free to use and modify. It is known for its ease of setup and administration, making it accessible to developers looking for a scalable and flexible database solution.
CouchDB software includes a native web interface i.e. Fauxton for administration of NoSQL database server.
Recommended Online Training: Understanding CouchDB 3: Learn Basic & Advanced NoSQL Skills
Couchbase vs CouchDB
Couchbase and CouchDB are both NoSQL database systems, but they have some key differences in terms of architecture, features, and use cases:
Couchbase
Architecture
- Distributed Key-Value Store: Couchbase is designed as a distributed key-value store with a document-oriented NoSQL database.
- Memcached Integration: It includes built-in caching capabilities with Memcached integration for faster data access.
- Multi-Cluster Replication: Supports cross-datacenter replication (XDCR) for geographically distributed clusters.
Data Model
- JSON Document Store: Couchbase stores data in JSON format as flexible documents, allowing for easy schema evolution and dynamic data models.
- Key-Value Operations: Alongside document storage, Couchbase supports key-value operations for efficient data retrieval.
Querying
- N1QL (SQL for JSON): Couchbase uses N1QL (pronounced “nickel”), a SQL-like query language that operates on JSON documents. This allows for powerful and flexible querying capabilities.
Scalability and Performance
- High Performance: Couchbase is known for its high performance and low-latency data access capabilities, suitable for applications requiring fast data retrieval and processing.
- Automatic Sharding: Automatically distributes data across nodes to achieve horizontal scalability.
Use Cases
- Real-Time Applications: Ideal for applications needing fast data access and high availability.
- Caching: Used as a caching layer in front of relational databases or other data stores.
- Multi-Cluster Deployments: Suitable for globally distributed applications requiring synchronized data across different geographical locations.
CouchDB
Architecture
- Single-Node or Small Cluster: CouchDB typically operates in a single-node or small cluster setup.
- Master-Master Replication: Supports bi-directional replication between databases, allowing each node to independently handle read and write operations.
Data Model
- JSON Document Store: Similar to Couchbase, CouchDB stores data in JSON format as documents, enabling flexible and schema-less data storage.
- Append-Only Storage: Uses an append-only storage model for data durability and consistency.
Querying
- MapReduce Views: CouchDB uses MapReduce views for querying and indexing data. Views are created using JavaScript functions to generate index keys and reduce functions for aggregations.
Consistency and Conflict Resolution
- Eventual Consistency: CouchDB prioritizes eventual consistency across distributed nodes, resolving conflicts through revision trees and conflict resolution algorithms.
Use Cases
- Offline-First Applications: Suitable for applications needing robust offline data synchronization capabilities.
- Decentralized Architectures: Used in environments where peer-to-peer replication and data sharing are important.
- Document Storage: Effective for applications requiring versioned document storage and conflict management.
Summary
- Couchbase is designed for high performance, scalability, and real-time data access, with features like N1QL querying and automatic sharding.
- CouchDB focuses on decentralized architectures, offline-first applications, and robust conflict resolution, utilizing MapReduce views and master-master replication.
Choosing between Couchbase and CouchDB depends on specific project requirements such as scalability needs, querying capabilities, and architectural preferences for data synchronization and consistency. Each database system offers unique strengths tailored to different use cases in modern application development.
Read Also: How to install Couchbase Server on CentOS 8
Environment Specification
We are using a minimal installed CentOS 8 virtual machine with following specification.
- CPU – 3.4 Ghz (2 cores)
- Memory – 2 GB
- Storage – 20 GB
- Operating System – CentOS Linux 8.2
- Hostname – couchdb-01.centlinux.com
- IP Address – 192.168.116.206 /24
Update your Linux Server
Connect with couchdb-01.centlinux.com as root user by using a ssh client.
It is a best practice to update installed software packages before installing anything new on Linux operating system.
Execute dnf command to update installed software packages in your Linux operating system.
# dnf -y update
After updating software packages, verify the new Kernel version.
# uname -r 4.18.0-193.6.3.el8_2.x86_64
Install EPEL Yum Repository
CouchDB database server requires some packages that are not available in standard yum repositories, therefore, you have to install EPEL (Extra Packages for Enterprise Linux) yum repository on your Linux server.
# dnf install -y epel-release
Install CouchDB Yum Repository
CouchDB database can be install on Linux from source or RPM packages. The RPM based installation is simple and straight forward, therefore we suggest that you should install this NoSQL database software from RPM packages.
Free RPM packages are distributed through their own official yum repository. Therefore, you need to install CouchDB yum repository in your Linux operating system.
Create a repo file by using vim text editor.
# vi /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo
And add following directives in this file.
[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
Build cache for newly installed yum repositories.
# dnf makecache CentOS-8 - AppStream 2.7 kB/s | 4.3 kB 00:01 CentOS-8 - Base 1.4 kB/s | 3.9 kB 00:02 CentOS-8 - Extras 1.4 kB/s | 1.5 kB 00:01 bintray--apache-couchdb-rpm 489 B/s | 1.3 kB 00:02 Extra Packages for Enterprise Linux Modular 8 - 12 kB/s | 117 kB 00:10 Extra Packages for Enterprise Linux 8 - x86_64 215 kB/s | 7.9 MB 00:37 Metadata cache created.
Install CouchDB Server on CentOS 8
You have set up the required yum repositories. Now you can install CouchDB Server on CentOS 8 by using dnf command.
# dnf install -y couchdb
NoSQL database software is installed in /opt/couchdb directory.
Edit CouchDB configuration file by using vim text editor.
# vi /opt/couchdb/etc/local.ini
Create an admin user and set a strong password for it. You have to locate the [admins] section and then add a admin user under this section. You can add as many admin users as you like here.
[admins] admin = Str0ngP@ssw0rd
Don’t worry about the password in plain text, because the CouchDB will automatically convert it to a hash at the time of service startup.
By default, CouchDB runs its Web UI (i.e. Fauxton) at the localhost interface only. But to access it from the network, you need to run it on other network interfaces as well.
Locate [chttpd] section and set following directives therein.
[chttpd] port = 5984 bind_address = 0.0.0.0
Enable and start CouchDB service.
# systemctl enable --now couchdb.service Created symlink /etc/systemd/system/multi-user.target.wants/couchdb.service â /usr/lib/systemd/system/couchdb.service.
Configure Linux Firewall
CouchDB service uses default port 5984/tcp. Therefore, you need to allow incoming traffic to this port from the network.
Execute firewall-cmd command to allow port 5984/tcp in Linux firewall.
# firewall-cmd --permanent --add-port=5984/tcp success # firewall-cmd --reload success
Accessing Fauxton Web UI
After successful startup of CouchDB service, you can now access the Fauxton web interface by opening the URL http://couchdb-01.centlinux.com:5984/_utils#setup in a web browser.
You will be redirected to the login page. You can use an admin user (that we have added in local.ini file) to login to Fauxton.
After login, the setup will ask you to configure CouchDB server as a single-node instance or set up a cluster. Click on “Configure as Single Node”.
Provide the admin user credentials, bind IP address and the service port. Click on “Configure Node”.
At the end of setup, it will ask you to configure replication. Ignore it and click on the Databases button at left sidebar.
You are now at the databases page. You can create your required databases from this page.
In the above screenshot, you can see the two system databases that are created during setup process and two user databases that are created by us for testing purpose.
Besides Fauxton web interface, you can also send HTTP commands to CouchDB instance by using curl command.
To create a CouchDB database, you can execute following command at Linux bash prompt.
# curl -u admin:Str0ngP@ssw0rd -X PUT http://127.0.0.1:5984/prod {"ok":true}
To list all the databases on your CouchDB server, you can send following command.
# curl -u admin:Str0ngP@ssw0rd -X GET http://127.0.0.1:5984/_all_dbs ["_replicator","_users","prod","test"]
To understand basics and architecture of CouchDB database, we recommend that you should buy and read CouchDB: The Definitive Guide: Time to Relax (PAID LINK) by O’Reilly Media.
Final Thoughts
Installing CouchDB Server on CentOS 8 opens up robust possibilities for scalable and efficient data storage solutions. Whether you’re a developer or system administrator, mastering CouchDB enhances your ability to manage and optimize data storage on CentOS 8.
For personalized assistance or detailed instructions on installing CouchDB Server, explore my Fiverr service: Linux Server Administration
Empower your data management capabilities with expert support today!