Site icon IT Tutorial

How To Install MongoDB 4.2 on RedHat/ CentOS 7 systems

As we discuss MongoDB in the previous Article About MongoDB, Why we use it? MongoDB’s Terminology and Implementation , MongoDB is an open-source NoSQL database.

Lots enhancements are released with the latest version MongoDB 4.2 to become more stable version easy to use in development and scaling.

MongoDB is a document-oriented database presented as two versions are released:

So in this tutorial we will show how to install MongoDB Community Edition using the package management system for these specifications as below:

First, to prepare MongoDB’s installation directly using the package management system (yum), it is required to add the MongoDB repository and configure the yum repository configuration file mongodb.repo:

#vi /etc/yum.repos.d/mongodb.repo

[MongoDB]

name=MongoDB Repository

baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/ x86_64/

gpgcheck=1

enabled=1

gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc

#yum repolist

Second, now we can install mongodb-org package directly using the package management system (yum).There is no easy that this command below to launch the yum package manager and it will automatically install the latest stable version available MongoDB and all its dependencies:

# sudo yum install –y mongodb-org

In the next step, we have just to start MongoDB service using the systemctl utility that launch the MongoDB init script as show the next command:

#sudo systemctl start mongod.service

#sudo tail /var/log/mongodb/mongod.log

#sudo systemctl enable mongod.service

# mongod –version

# sudo systemctl status mongod.service

# sudo systemctl reload mongod

# mongo

> use mydb;

#sudo systemctl stop mongod

 

Exit mobile version