How to install MongoDB in CentOS 7

MONGODB
MongoDB is a document-oriented database. It is free and open-source. It is written in c++. It is NoSQL based database.
PREREQUISITES
  • CentOS- 64 bit
  • User with sudo permission
What is YUM?
YUM (Yellowdog Updater Modified) is an open source package management tool for RPM (RedHat Package Manager) based Linux systems.

INSTALLATION PROCEDURE

1.)INSTALL THE NANO TEXT EDITOR
Install the nano editor by typing
sudo yum install nano
2.)ADD THE MONGODB REPOSITORY
MongoDB provides officially supported packages in their own repository. This repository contains the following packages:
  • mongodb-org - This package is a metapackage that will automatically install the four component packages listed below.
  • mongodb-org-server - This package contains the mongod daemon and associated configuration and init scripts.
  • mongodb-org-mongos - This package contains the mongos daemon.
  • mongodb-org-shell - This package contains the mongo shell.
  • mongodb-org-tools - This package contains the following MongoDB tools: mongoimport bsondump, mongodump, mongoexport, mongofiles, mongooplog, mongoperf, mongorestore, mongostat, and mongotop.
Create a  mongodb-org.repo file in etc/yum.repos.d/ and open it in nano text editor by typing
sudo nano /etc/yum.repos.d/mongodb-org.repo
Populate the mongodb-org.repo by adding
[mongodb-org-3.4]

name=MongoDB Repository

baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/

gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
Before installing the MongoDB, update all the packages
sudo yum -y update
3.)INSTALL THE MONGODB 
And then install the MongoDB by
sudo yum install -y mongodb-org
If you need to install the specific version of MongoDB means, simply append the version number to each package
sudo yum install -y mongodb-org-3.4 mongodb-org-server-3.4 mongodb-org-shell-3.4 mongodb-org-mongos-3.4 mongodb-org-tools-3.4
yum will upgrade the MongoDB package whenever a new version becomes available. If you don’t need this means, pin a package. To pin a package, in  /etc/yum.conf file. Go to  /etc/yum.conf file by
sudo nano  /etc/yum.conf
Ad the below lines to restrict that one
exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools
REFERENCE: https://docs.mongodb.com/v2.8/tutorial/install-mongodb-on-red-hat/

Comments