/    /  MongoDB – Installation

MongoDB – Installation:

Note: MongoDB 3.2 deprecates the support for RHEL 5.

MongoDB Installation:

This installation guide will be useful for installing MongoDB on Linux (RHEL). Once after the Linux host is ready with an internet connection, below is the process of installation.

1. Create a Linux user called mongo ( as you wish ) . if you wish to install in root , then mongo user is not mandatory

useradd mongo 
passwd mongo

2. Create and configure /etc/yum.repos.d/mongodb-org-3.4.repo file to do the installation using Yum utility.

3. Please copy and paste the below lines in the repository file.

[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

4. Once the repository file is ready, give the below command in the terminal.

sudo yum install -y mongodb-org

By giving the above command, request through the repository file would reach to MongoDB server to get all the required packages of latest stable version of MongoDB.

By default, the port 27017 should be available , if not then enable the default port 27017 which is used by MongoDB using the below command.

semanage port -a -t mongod_port_t -p tcp 27017

Start the Mongo DB:

sudo service mongod start

Check if the mongo database is already running 

1. ps -ef | grep mongod
2. sudo service mongod status

Mongo DB file locations 

Error log file location: /var/log/mongodb/mongod.log
Configuration location: /etc/mongod.conf
Database file location: /var/lib/mongo
Log files location: /var/log/mongodb

Verify the running status of mongo DB 

Check if the mongo database is already running

1. ps -ef | grep mongod
2. sudo service mongod status