CentOS 8.2 deploying CouchDB 3.3 database

Time:2021-7-28

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

What is Apache CouchDB?

CouchDBByApache Software FoundationOpen source database management system. It’s inIn ErlangDevelopedNoSQL document storagedatabase

CouchDBIt uses a variety of formats and protocols to store, transmit and process its dataJSON (JavaScript object representation)Storing data, usingMapReduceUsing JavaScript as query language and APIHTTP

Unlike relational databases, CouchDB databases do not store data and relationships in tables. Instead, each database is a collection of independent documents. Each document maintains its own data and independent architecture.

CouchDB software includes a local web interface, which is used to manage CouchDB database serverFauxton

Environmental specifications:


  • CPU: 3.4 GHz (2 cores)
  • Memory:2 GB
  • Storage space:20 GB
  • operating system:CentOS 8.2
  • host name:couchdb.lianglab.cn
  • IP address:192.168.6.200/24

Step 1: update CentOS 8 package


through the use ofsshClient torootUser identity andcouchdb.lianglab.cnconnect.

The best practice is to update the installed packages before installing anything new on the CentOS 8 operating system.

usednfCommand to update installed packages in CentOS 8.

[[email protected] ~]# hostnamectl set-hostname couchdb.lianglab.cn


[[email protected] ~]# 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 the package, verify the new kernel version.

[[email protected] ~]# uname -r
4.18.0-193.el8.x86_64
[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 8.2.2004 (Core)

Step 2: install EPEL Yum repository on CentOS 8


CouchDBThe database server requires some packages that are not available in the standard Yum repository, so we installed them on the CentOS 8 serverEPEL (additional package for Enterprise Linux)Yum repository.

[[email protected] ~]# dnf install -y epel-release
================================================================================
 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!

Step 3: install CouchDB Yum repository on CentOS 8


CouchDB database can be installed on CentOS 8 through source or RPM packages. The RPM based installation is straightforward, so we install CouchDB from the RPM package.

CouchDB database RPM packages are distributed through their own official Yum repository. Therefore, we added the CouchDB Yum repository to the CentOS 8 operating system.

【1】 UsevimThe editor creates a repo file

[[email protected] ~]# vi /etc/yum.repos.d/bintray-apache-couchdb-rpm.repo

Add the following to the 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

【2】 Build cache from the newly added reop file Yum repository

[[email protected] ~]# dnf makecache
CentOS-8 - Base - mirrors.tongdun.cn                                                       
CentOS-8 - Extras - mirrors.tongdun.cn                                                     
CentOS-8 - AppStream - mirrors.tongdun.cn                                                  
bintray--apache-couchdb-rpm                                                                
Extra Packages for Enterprise Linux 8 - x86_64                                             
Extra Packages for Enterprise Linux 8 - x86_64 - Debug                                     
Extra Packages for Enterprise Linux 8 - x86_64 - Source                                    
Metadata cache created.
[[email protected] ~]#

Step 4: installing Apache CouchDB


【1】 We have established the required Yum repository. Now, we can usednfCommand to install CouchDB software.

[[email protected] ~]# dnf list couchdb
Last metadata expiration check: 0:00:39 ago on Fri 25 Dec 2020 10:42:23 PM CST.
Available Packages
couchdb.x86_64                   3.1.1-1.el8                   bintray--apache-couchdb-rpm
[[email protected] ~]# dnf install -y couchdb
Last metadata expiration check: 0:00:52 ago on Fri 25 Dec 2020 10:42:23 PM CST.
Dependencies resolved.
==========================================================================================
 Package        Architecture  Version            Repository                          Size
==========================================================================================
Installing:
 couchdb        x86_64        3.1.1-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.1-1.el8.x86_64.rpm                            3.5 MB/s |  24 MB     00:06    
------------------------------------------------------------------------------------------
Total                                                     3.5 MB/s |  24 MB     00:06     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                  1/1 
  Running scriptlet: couchdb-3.1.1-1.el8.x86_64                                       1/1 
  Installing       : couchdb-3.1.1-1.el8.x86_64                                       1/1 
  Running scriptlet: couchdb-3.1.1-1.el8.x86_64                                       1/1 
  Verifying        : couchdb-3.1.1-1.el8.x86_64                                       1/1 
Installed products updated.

Installed:
  couchdb-3.1.1-1.el8.x86_64                                                              

Complete!

CouchDB software is installed in/opt/couchdbIn the directory.

【2】 UseviEdit the CouchDB configuration file with the editor.

[[email protected] ~]# vi /opt/couchdb/etc/local.ini

【3】 Create an administrator user and set a strong password for it. You must find[admins]Section, and then add an admin user under this section. Any number of administrator users can be added here.

Before modification
[admins]
;admin = mysecretpassword



After modification
[admins]
admin = [email protected]

Don’t worry about plain text passwords, because CouchDB automatically converts them to hash values when the service starts.

【4】 CouchDB runs its Web UI only on the localhost interface (i.eFauxton)。 But to access it from the network, we also need to run it on other network interfaces.

find[chttpd]Section and set the following instructions in it.

Before modification
[chttpd]
;port = 5984
;bind_address = 127.0.0.1



[chttpd]
port = 5984
bind_address = 0.0.0.0

【5】 Start CouchDB service.

[[email protected] ~]# systemctl enable --now couchdb.service
Created symlink /etc/systemd/system/multi-user.target.wants/couchdb.service → /usr/lib/systemd/system/couchdb.service.

【6】 View service status and monitoring port information

[[email protected] ~]# systemctl status couchdb.service
● couchdb.service - Apache CouchDB
   Loaded: loaded (/usr/lib/systemd/system/couchdb.service; enabled; vendor preset: disab>
   Active: active (running) since Fri 2020-12-25 23:00:03 CST; 1min 43s ago
 Main PID: 109712 (beam.smp)
    Tasks: 40 (limit: 49642)
   Memory: 34.3M
   CGroup: /system.slice/couchdb.service
           ├─109712 /opt/couchdb/bin/../erts-9.3.3.14/bin/beam.smp -K true -A 16 -Bd -- ->
           ├─109737 /opt/couchdb/bin/../erts-9.3.3.14/bin/epmd -daemon
           └─109756 erl_child_setup 65536

Dec 25 23:00:03 couchdb.lianglab.cn systemd[1]: Started Apache CouchDB.

[[email protected] ~]# netstat -anptl | grep 5984
tcp        0      0 0.0.0.0:5984            0.0.0.0:*               LISTEN      109712/beam.smp

【7】 Allow ports in Linux Firewall5984/tcp

The CouchDB service uses the default port5984。 Therefore, we need to allow incoming traffic from the network to the port.

[[email protected] ~]# firewall-cmd --permanent --add-port=5984/tcp
success
[[email protected] ~]# firewall-cmd --reload
success

Step 5: access CouchDB Web UI


【1】 After successfully starting the CouchDB service, we can now open the URL in a web browserhttp://192.168.6.200:5984/_utils/#loginTo visitFauxtonWeb interface.

【2】 CouchDB login page, you can use the administrator user (we havelocal.ini(the user is added to the file) log in to fauxton.

【3】 Once you have logged into CouchDB, you will be required to log in as aSingle node instanceorSet up cluster。 single click“Configure as single node”

【4】 Provide administrator user credentials and bind IP address and service port. click“Configuration node”

【5】 At the end of CouchDB installation, it will ask you to configure replication. Ignore it, and then click on the left sidebar“DatabaseButton.

You are now on the database page. You can create the required database from this page.

Here, you can see the two system databases created during CouchDB installation and the two user databases we created for testing purposes.

exceptFauxtonIn addition to the web interface, we can also usecurlCommand sends an HTTP command to the CouchDB instance.

【6】 To create a CouchDB database, we can use the following command.

[[email protected] ~]# curl -u admin:[email protected] -X PUT http://127.0.0.1:5984/lianglab
{"ok":true}

[[email protected] ~]# curl -u admin:[email protected] -X GET http://127.0.0.1:5984/lianglab
{"db_name":"lianglab","purge_seq":"0-g1AAAABXeJzLYWBgYMpgTmEQTM4vTc5ISXIwNDLXMwBCwxyQVB4LkGRoAFL_gSArkQGP2kSGpHqIoiwAtOgYRA","update_seq":"0-g1AAAABXeJzLYWBgYMpgTmEQTM4vTc5ISXIwNDLXMwBCwxyQVB4LkGRoAFL_gSArkQGP2kSGpHqIoiwAtOgYRA","sizes":{"file":16700,"external":0,"active":0},"props":{"partitioned":true},"doc_del_count":0,"doc_count":0,"disk_format_version":8,"compact_running":false,"cluster":{"q":2,"n":1,"w":1,"r":1},"instance_start_time":"0"}
[[email protected] ~]#

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

[[email protected] ~]# curl -u admin:[email protected] -X GET http://127.0.0.1:5984/_all_dbs
["_replicator","_users","lianglab"]

Conclusion:

Advertising time:


  • About me: National 7 * 24 efficient maintenance service
  • WeChat:lianglab
  • QQ:867266199
  • Taobao storeNational 7 * 24 efficient maintenance service
  • National efficient maintenance: provide cloud computing consulting, architecture design and cost reduction for small and medium-sized enterprises.

We have successfully installed Apache CouchDB 3.3 in CentOS 8 to understand the basics and the database architecture of CouchDB. We suggest that you should buy and read itCouchDB: The Definitive Guide: Time to RelaxfromO’Reilly media

Recommended Today

VBS obtains the operating system and its version number

VBS obtains the operating system and its version number ? 1 2 3 4 5 6 7 8 9 10 11 12 ‘************************************** ‘*by r05e ‘* operating system and its version number ‘************************************** strComputer = “.” Set objWMIService = GetObject(“winmgmts:” _  & “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2”) Set colOperatingSystems = objWMIService.ExecQuery _  (“Select * from […]