How to install Mongodb on Centos/Redhat

In this tutorial,  How to install MongoDB on Centos. The Local Remi Repository only supports the old MongoDB packages by default. Need to upgrade to higher version need to point to the server of MongoDB. Linux the essential for DevOps Roles.

My environment

  • Centos 7/6, Redhat.
  • MongoDB Version 4.0

Install Mongodb on Centos/Redhat

Step 1. Disable the current Repository on Centos.

Failure to do this will result in conflicting package MongoDB on Epel Repository. Installing a package management software package:

$ sudo yum install yum-utils

Disable Repository ‘remi- *’ and internet MongoDB package if Pre-ordered:

$ sudo yum-config-manager --disable \*epel\*
$ sudo yum-config-manager --disable \*mongo\*

Step 2. Enable Repository MongoDB.

Creating a “/etc/yum.repos.d/mongodb.repo” file with the content as below

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

Now, You can install MongoDB directly using yum

$ sudo yum install mongodb-org

The screen output terminal:

Install MongoDB

Step 3. To disable MongoDB and Enable back the repository epel.

$ sudo yum-config-manager --enable \*epel\*
$ sudo yum-config-manager --disable \*mongo\*

To check the MongoDB version

$ mongod --version

The screen output terminal:

Install MongoDB version

Reference to Mongodb

Conclusion

Thought the article, You can “Install MongoDB” as above. I hope will this your helpful.

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.