MongoDB Installation on Centos

MongoDB is a scalable, document-oriented, open source, NoSQL database application which is developed with C ++. MongoDB is used especially in speedy and traditional relational databases (RDBMS) that are cumbersome and slow. That is a non-relational database. One of the distinctive features of MongoDB is, it can store data in JSON format.

MongoDb Json NoSQL

Features of MongoDB:

  • Scalable. We may add machines in situations where the data size increases or when we have performance bottlenecks
  • The data is stored in document format. We can use JSON data here
  • Since the data is stored in JSON format, even if the incoming data structure changes, there is no problem in saving.
  • Multiple copies of data can be stored and no data loss (Replication)
  • We can quickly get to the data by indexing the data

MongoDB Cluster

Now we have some information about MongoDB, let’s move on installation.

Installation

In this tutorial, we will install MongoDB on Centos 6.x – 64 bit operating system.

First we need to install nano and add repo with nano;

yum – y install nano
nano – w / etc / yum . repos . d / mongodb . repo

Add if your system is 64-bit, please ad the code below;

[ mongodb ]
name = MongoDB Repository
baseurl = http : //downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck = 0
enabled = 1

If your system is 32-bit, add the below code;

[ mongodb ]
name = MongoDB Repository
baseurl = http : //downloads-distro.mongodb.org/repo/redhat/os/i686/
gpgcheck = 0
enabled = 1

After this process we can record it and exit nano. Now we can start to install MongoDB with simple command;

yum install mongo-10gen mongo-10gen-server

When prompted Is this ok [y/N]: , simply type y and then hit the enter key.

Now Mongodb is installed, we should add the service and start it;

chkconfig mongod on
service mongod start

We should see;

Start

To check the Mongodb status we can use the command below;

service mongod status

Now we will be accessing MongoDB Shell environment with mongo command.Output will be similar to the following image:

We can list all databases with the command show dbs; Apply it after you enter the mongo command and have a smillar screen like above;

 show dbs

Now, let’s create a database called datakeepers and list it;

Example : The commands to create a database called datakeepers;

use datakeepers ;
s = { Name : “virtualservers.co.za” }
db . testData . insert ( s ) ;

Now, when we list all databases with command show dbs, we will see datakeepers;

MongoDB server’s default listening port is 27017, if you want to run in a different port (exp 22222) please use the command below;

mongo –port 22222

Shutdown MongoDB

service mongod stop

You can install MongoDB on CentOS in this tutorial in all Linux VPS packages.

Leave A Comment?