Install MongoDB 3.4 on CentOS 6 and 7


MongoDB is a scalable, high-performance, open source NoSQL database. The database is document-oriented so it manages collections of JSON-like documents. Many applications can thus model data in a more natural way, as data can be nested in complex hierarchies and still be queryable and indexable.

We are assuming that you have root permission, otherwise, you may start commands with “sudo”.

Install MongoDB

For installing the latest stable version of MongoDB you should add MongoDB repository first.

Adding MongoDB Repository

Move to the following directory:

cd /etc/yum.repos.d/

Create the following file with your favorite text editor:

nano mongodb-org-3.4.repo

For the latest stable version of MongoDB paste the following line in the file then save and exit:

name=MongoDB Repository

Installing MongoDB

Update your repositories list executing the following command:

yum repolist

Now you can install the latest stable version of MongoDB using “Yum”:

yum install mongodb-org -y

Configuring SELINUX

If you are using SELinux, you must configure SELinux to allow MongoDB to start on Red Hat Linux-based systems

If SELinux is in enforcing mode, enable access to the relevant ports that the MongoDB deployment will use (e.g. 27017).

semanage port -a -t mongod_port_t -p tcp 27017

Manage your MongoDB Service

You can manage your MongoDB service with “systemctl”:

For making MongoDB run at startup:

systemctl enable mongod


chkconfig mongod on

For Start/Stop MongoDB service:

systemctl start mongod

systemctl stop mongod


service mongod start

service mongod stop

See your MongoDB status:

systemctl status mongod


service mongod status

Check out MongoDB official website for more information and news!

Be the first to comment

Leave a Reply

Your email address will not be published.