Installing mongodb on centos7

Installing mongodb on centos7: To install the mongodb server in centos7 first you have to add the mongodb repo:

vim /etc/yum.repos.d/mongodb.repo

Paste this into the file:

    name=MongoDB Repository

Next, update your yum database and install the mongodb server

yum update && yum install mongodb-org mongodb-org-server

Your system will now update its repo list, download mongodb and the mongodb server. If you have installed the mongodb packages from epel, then the mongodb-org ones will conflict, you’ll have to yum erase the existing ones first.

You need to allow mongodb through SELinux – on centos7 semanage is provided by policycoreutils-python

    yum install policycoreutils-python
    semanage port -a -t mongod_port_t -p tcp 27017

To start the mongodb service, run this (mongod is a sysV service)

service start mongod

To check that mongodb is listening, run this:

cat /var/log/mongodb/mongod.log

If you see ‘waiting for connections on port XXXX’ then you are good to go.
And to enable mongodb on boot, run this:

chkconfig mongod on


Leave a Reply