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:


    [mongodb]
    name=MongoDB Repository
    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
    gpgcheck=0
    enabled=1

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

sources:
https://docs.mongodb.org/getting-started/shell/tutorial/install-mongodb-on-red-hat/
http://www.cyberciti.biz/faq/redhat-install-semanage-selinux-command-rpm/

Leave a Reply