Mongo DB on centos

cat > /etc/yum.repos.d/mongodb-org-3.2.repo <<EOF
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/stable/x86_64/
gpgcheck=0
enabled=1
EOF

Now that our repo is defined, we can just install MongoDB with YUM:

yum install -y mongodb-org policycoreutils-python-2.2.5-20.el7.x86_64

By default, SELinux is not going to allow MongoDB to run on the default interface. So we need to adjust the policy for that. Thesemanage command is not installed on CentOS 7 Minimum by default, this is why we added the policycoreutils above.

semanage port -a -t mongod_port_t -p tcp 27017

You could turn SELinux off, of course, or set to permissive, but that is not advised. Correctly configuring SELinux is more secure.

Now we can start our database:

systemctl start mongod
systemctl enable mongod

If all has gone well, MongoDB will be running on port 27017. If this is going to be used for a local installation of an application, leave this port closed on the firewall. If you need to open the firewall for remote clients to attach we will open it below. Keep in mind that exposing MongoDB publicly will be a security nightmare, so consider proper precautions such as locking the port to being exposed to a single IP address or range.

firewall-cmd --zone=public --add-port=27017/tcp --permanent
firewall-cmd --reload


Source :http://mangolassi.it/topic/8075/installing-mongodb-3-2-on-centos-7
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s