A brief overview and installation of MongoDB

MongoDB is an open source application document-oriented database which is available under the GPL for free. It was initially built to be scalable, open source, high performance and document oriented database. The Document Oriented Database falls under the category of a "no SQL databases". Usually, databases in general would be classified under RDBMS, OLAP or NOSQL. MongoDB is a NOSQL database.


Installation of MongoDB is very simple either through compilation or through the official repository. Follow the instructions below to install MongoDB. Lets see how to install MongoDB on a centos7 machine.

1.Create the MongoDB repo at /etc/yum.repos.d as indicated on the official MongoDB website.

vim /etc/yum.repos.d/MongoDB.repo and add the following lines:

name=MongoDB Repository

2. Then, you would simply need to do the installation.

yum -y install mongodb-org

3. After the installation, you can start the daemon as follows:

systemctl mongod start

4. You would noticed that the daemon, by default would run under the port 27017

[[email protected] yum.repos.d]# netstat -ntpl | grep -i mongo
tcp        0      0*               LISTEN      9692/mongod 

5. By typing mongo on the terminal you would be prompted to the MongoDB CLI

How NOSQL came to the scene? It was found that Relational Databases were not capable of handling big data. Through, there is a serious debate on this issue, NOSQL was the answer to handle big data.  Horizontal scalability was found missing in RDBMS compared to NOSQL. In RDBMS, entity is represented by a table compared to MongoDB, table is comparable to collections.

Some features of MongoDB is that it support:

Ad hoc - you can do a search by field, range queries and regular expressions

Indexing - Any field in a particular document can be indexed

Replication - Master and slave replication is supported. A master can performs reads and writes and a slave will copies data from the master where it can only be used for reads or backup.

Data Duplication - MongoDB can run on multiple servers where data is duplicated to keep the system up and running in case of hardware failure.

Load Balancing - Since horizontal scalability is one of MongoDB feature, load balancing can be setup between machines. New machines can be added to a running database.