Apache CouchDB is a free and open source NoSQL based database management system. CouchDB is a single node database which can also be clustered to run on different servers. CouchDB uses HTTP protocol and JSON format for sending the data. Hence the database is compatible with all the software which supports this. It is very reliable and secure database management system and used by numerous web applications.
In this tutorial, we will be installing Apache CouchDB on CentOS 7 server.
CouchDB does not require any special hardware requirements. It can be installed on servers with a small amount of RAM to very large servers according to your needs. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Once the system is updated, you will need to install some dependencies which are required to install CouchDB. Some of the dependencies are not available on default YUM repository, hence you will need to install EPEL repository also. Run the following command for same.
yum -y install epel-releaseyum -y update
You can install the dependencies using the following command.
You can now access the admin panel using the following link.
To check if everything has installed correctly, you can access the following link.
If you want CouchDB instance to start automatically, you can setup Systemd service. It is recommended to create a systemd service for running CouchDB so that it can run in the background and can be automatically started on failures and boot time. Run the following command to create a systemd service file.
If you do not have nano installed, you can run yum -y install nano. Now paste the following text into the nano editor.
Now you can start CouchDB service and configure it to automatically start at boot time using following commands.
systemctl start couchdbsystemctl enable couchdb
To check if CouchDB service is started correctly, you can run the following command to check the status of the CouchDB service.
systemctl status couchdb You should get output similar to shown below.
[root@liptan-pc ]# systemctl status couchdb
● couchdb.service - CouchDB service
Loaded: loaded (/etc/systemd/system/couchdb.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2017-05-12 11:28:59 UTC; 8s ago
Main PID: 6354 (beam)
├─6354 /home/couchdb/couchdb/bin/../erts-5.10.4/bin/beam -K true -A 16 -Bd -- -root /home/couchdb/couchdb/bin...
├─6381 sh -s disksup
May 12 11:28:59 liptan-pc couchdb: [info] 2017-05-12T11:28:59.700471Z couchdb@localhost <0.7.0> --------...lhost
By default the server will listen to localhost on port 5984 only, if you want your CouchDB instance to be accessed from everywhere you will need to edit the CouchDB configuration file, run the following command to open the configuration file with nano editor.
Find the following lines into the file:
;port = 5984
;bind_address = 127.0.0.1
Uncomment the lines and change the lines as shown below.
port = 5984
bind_address = 0.0.0.0
Now restart the CouchDB service.
systemctl restart couchdb
Now you will need to disable your SELinux because reverse proxy does not work with SELinux policies. To temporary disable SELinux without restarting the server, run the following command.
To completely disable the SELinux you will need to edit /etc/selinux/config file.
If you don't have nano installed, you can install it using yum -y install nano Find the following line:
Change it to:
Now you will need to reboot your server so that the new configuration can take effect. Once the server is up again you can access your application at the following URL.
In this tutorial, we learned to install CouchDB on CentOS 7. You can now use CouchDB to create and store data in NoSQL database. Make sure that you create an admin user by clicking Admin Party! option from the sidebar.
Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you...