How to install Mongodb on Rhel 7 / Centos 7

how to install mongodb on rhel7/centos7

Based on experience on how to install mongodb on rhel 7 or Centos 7. in this article I will install Mongodb version 3.4

1.create mongodb repository /etc/yum.repos.d/mongodb-3.4.repo and paste lines below.

name=MongoDB Repository

and then, install mongodb packages.

 yum -y install mongodb-org 

you can geting packages


Note: To prevent unintended upgrades, the official MongoDB documentation advises to pin the various packages by adding the following directive in the /etc/yum.conf file:


The number of processes available for MongoDB in the system is not enough, you need to change the default settings by editing the /etc/security/limits.d/20-nproc.conf file and paste the following lines at the end.

mongod soft nproc 64000
mongod hard nproc 64000
mongod soft nofile 64000
mongod hard nofile 64000 

default dbpath mongodb /var/lib/mongo yu can look at /etc/mongod.conf

if you want to move to other directory or How to change mongodb default data path you can change /etc/mongod.conf and then change dbpath : /var/lib/mongo to your db path you want for example dbpath :/home/jagolinux and  you can change mongodb log here.

allow mongodb port on selinux

 firewall-cmd --permanent --add-port=27017/tcp

firewall-cmd --reload 

and then start the service and enable service for starting automatically after system reboot mongodb.

 systemctl start mongod

systemctl enable mongod

type mongo for used mongodb shell

Facebook Comments