Install Apache CouchDB on CentOS 8 - CentLinux

Latest

Monday, 31 August 2020

Install Apache CouchDB on CentOS 8

Install Apache CouchDB on CentOS 8

CouchDB is an open-source, document-oriented NoSQL database. In this article, you will learn how to install Apache CouchDB on CentOS 8.

 

Table of Contents:

     

    What is Apache CouchDB? :

    CouchDB is an open-source database management system, developed by Apache Software Foundation. It is a NoSQL document-store database developed in ErLang.

    CouchDB uses multiple formats and protocols to store, transfer, and process its data, it uses JSON (JavaScript Object Notation) to store data, JavaScript as its query language using MapReduce, and HTTP for an API.

    Unlike a relational database, a CouchDB database does not store data and relationships in tables. Instead, each database is a collection of independent documents. Each document maintains its own data and self-contained schema.

    CouchDB software includes a native web interface i.e. Fauxton for administration of CouchDB database server.

     

    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 8.2
    • Hostname – couchdb-01.centlinux.com
    • IP Address - 192.168.116.206 /24

     

    Updating CentOS 8 Software Packages:

    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 CentOS 8 operating system.

    Use dnf command to update installed software packages in CentOS 8.

    [root@couchdb-01 ~]# dnf -y update ... Upgraded: NetworkManager-1:1.22.8-5.el8_2.x86_64 NetworkManager-libnm-1:1.22.8-5.el8_2.x86_64 NetworkManager-team-1:1.22.8-5.el8_2.x86_64 NetworkManager-tui-1:1.22.8-5.el8_2.x86_64 bind-export-libs-32:9.11.13-5.el8_2.x86_64 ca-certificates-2020.2.41-80.0.el8_2.noarch dbus-1:1.12.8-10.el8_2.x86_64 dbus-common-1:1.12.8-10.el8_2.noarch dbus-daemon-1:1.12.8-10.el8_2.x86_64 dbus-libs-1:1.12.8-10.el8_2.x86_64 dbus-tools-1:1.12.8-10.el8_2.x86_64 dnf-4.2.17-7.el8_2.noarch dnf-data-4.2.17-7.el8_2.noarch gnutls-3.6.8-11.el8_2.x86_64 grub2-common-1:2.02-87.el8_2.noarch grub2-pc-1:2.02-87.el8_2.x86_64 grub2-pc-modules-1:2.02-87.el8_2.noarch grub2-tools-1:2.02-87.el8_2.x86_64 grub2-tools-efi-1:2.02-87.el8_2.x86_64 grub2-tools-extra-1:2.02-87.el8_2.x86_64 grub2-tools-minimal-1:2.02-87.el8_2.x86_64 iptables-1.8.4-10.el8_2.1.x86_64 iptables-ebtables-1.8.4-10.el8_2.1.x86_64 iptables-libs-1.8.4-10.el8_2.1.x86_64 kernel-tools-4.18.0-193.14.2.el8_2.x86_64 kernel-tools-libs-4.18.0-193.14.2.el8_2.x86_64 libdnf-0.39.1-6.el8_2.x86_64 libnghttp2-1.33.0-3.el8_2.1.x86_64 microcode_ctl-4:20191115-4.20200609.1.el8_2.x86_64 open-vm-tools-11.0.5-3.el8.x86_64 python3-dnf-4.2.17-7.el8_2.noarch python3-hawkey-0.39.1-6.el8_2.x86_64 python3-libdnf-0.39.1-6.el8_2.x86_64 python3-perf-4.18.0-193.14.2.el8_2.x86_64 selinux-policy-3.14.3-41.el8_2.5.noarch selinux-policy-targeted-3.14.3-41.el8_2.5.noarch systemd-239-31.el8_2.2.x86_64 systemd-libs-239-31.el8_2.2.x86_64 systemd-pam-239-31.el8_2.2.x86_64 systemd-udev-239-31.el8_2.2.x86_64 yum-4.2.17-7.el8_2.noarch Installed: kernel-4.18.0-193.14.2.el8_2.x86_64 kernel-core-4.18.0-193.14.2.el8_2.x86_64 kernel-modules-4.18.0-193.14.2.el8_2.x86_64 Removed: kernel-4.18.0-147.5.1.el8_1.x86_64 kernel-core-4.18.0-147.5.1.el8_1.x86_64 kernel-modules-4.18.0-147.5.1.el8_1.x86_64 Complete!

    After upgrading software packages, verify the new Kernel version.

    [root@couchdb-01 ~]# uname -r 4.18.0-193.6.3.el8_2.x86_64

     

    Installing EPEL Yum Repository on CentOS 8:

    CouchDB database server requires some packages that are not available in standard yum repositories, therefore, we are installing EPEL (Extra Packages for Enterprise Linux) yum repository on our CentOS 8 server.

    [root@couchdb-01 ~]# dnf install -y epel-release Last metadata expiration check: 0:00:32 ago on Sun 30 Aug 2020 01:44:48 AM PKT. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: epel-release noarch 8-8.el8 extras 23 k Transaction Summary ================================================================================ Install 1 Package Total download size: 23 k Installed size: 32 k Downloading Packages: epel-release-8-8.el8.noarch.rpm 34 kB/s | 23 kB 00:00 -------------------------------------------------------------------------------- Total 7.4 kB/s | 23 kB 00:03 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : epel-release-8-8.el8.noarch 1/1 Running scriptlet: epel-release-8-8.el8.noarch 1/1 Verifying : epel-release-8-8.el8.noarch 1/1 Installed: epel-release-8-8.el8.noarch Complete!

     

    Installing CouchDB Yum Repository on CentOS 8:

    CouchDB database can be installed on CentOS 8 from source or RPM packages. The RPM based installation is simple and straight forward, therefore we are installing CouchDB from RPM packages.

    CouchDB database RPM packages are distributed through their own offical yum repository. Therefore, we are adding CouchDB yum repository in our CentOS 8 operating system.

    Create a repo file by using vim editor.

    [root@couchdb-01 ~]# 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.

    [root@couchdb-01 ~]# 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.

     

    Installing Apache CouchDB on CentOS 8:

    We have set up the required yum repositories. Now we can install CouchDB software by using dnf command.

    [root@couchdb-01 ~]# dnf install -y couchdb Last metadata expiration check: 0:00:50 ago on Sun 30 Aug 2020 01:46:27 AM PKT. Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: couchdb x86_64 3.1.0-1.el8 bintray--apache-couchdb-rpm 24 M Transaction Summary ================================================================================ Install 1 Package Total download size: 24 M Installed size: 51 M Downloading Packages: couchdb-3.1.0-1.el8.x86_64.rpm 901 kB/s | 24 MB 00:26 -------------------------------------------------------------------------------- Total 901 kB/s | 24 MB 00:26 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: couchdb-3.1.0-1.el8.x86_64 1/1 Installing : couchdb-3.1.0-1.el8.x86_64 1/1 Running scriptlet: couchdb-3.1.0-1.el8.x86_64 1/1 Verifying : couchdb-3.1.0-1.el8.x86_64 1/1 Installed: couchdb-3.1.0-1.el8.x86_64 Complete!

    CouchDB software is installed in /opt/couchdb directory.

    Edit CouchDB configuration file by using vim editor.

    [root@couchdb-01 ~]# 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, we 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.

    [root@couchdb-01 ~]# systemctl enable --now couchdb.service Created symlink /etc/systemd/system/multi-user.target.wants/couchdb.service รข /usr/lib/systemd/system/couchdb.service.

    CouchDB service uses default port 5984. Therefore, we need to allow incoming traffic to this port from the network.

    Use firewall-cmd command to allow port 5984/tcp in Linux firewall.

    [root@couchdb-01 ~]# firewall-cmd --permanent --add-port=5984/tcp success [root@couchdb-01 ~]# firewall-cmd --reload success

     

    Accessing CouchDB Web UI:

    After Successful startup of CouchDB service, we can now access the Fauxton web interface by opening the URL http://couchdb-01.centlinux.com:5984/_utils#setup in a web browser.

    01-install-apache-couchdb-on-centos-8-fauxton-login

    You will be redirected to the CouchDB login page. You can use an admin user (that we have added in local.ini file) to login to Fauxton.

    02-install-apache-couchdb-on-centos-8-setup

    After login, the setup will ask you to configure CouchDB as a single-node instance or set up a cluster. Click on "Configure as Single Node".

    03-install-apache-couchdb-on-centos-8-setup-single-node

    Provide the admin user credentials, bind IP address and the service port. Click on "Configure Node".

    04-install-apache-couchdb-on-centos-8-setup-finish

    At the end of CouchDB setup, it will asked for you to configure replication. Ignore it and click on the Databases button at left sidebar.

    05-install-apache-couchdb-on-centos-8-databases

    You are now at the databases page. You can create your required databases from this page.

    Here, you can see the two system databases that are created during CouchDB setup process and two user databases that are created by us for testing purpose.

    Besides Fauxton web interface, we can also send HTTP commands to CouchDB instance by using curl command.

    To create a CouchDB database, we can use following command.

    [root@couchdb-01 ~]# curl -u admin:Str0ngP@ssw0rd -X PUT http://127.0.0.1:5984/prod {"ok":true}

    To list all the databases on our CouchDB server, we can send following command.

    [root@couchdb-01 ~]# curl -u admin:Str0ngP@ssw0rd -X GET http://127.0.0.1:5984/_all_dbs ["_replicator","_users","prod","test"]

     

    Conclusion:

    We have successfully installed Apache CouchDB on CentOS 8. For understanding basics and architecture of CouchDB database, we recommend that you should buy and read CouchDB: The Definitive Guide: Time to Relax by O'Reilly Media.

    No comments:

    Post a comment