Setup MongoDB on CentOS

Preparation

Make sure your system is up-to-date.

sudo yum -y update
During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor.
sudo yum -y install vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 100

Install MongoDB

Follow the official MongoDB installation guide for CentOS.

Configure MongoDB for Relution

If you are going to install Relution on another machine, you need to configure MongoDB to listen on all network interfaces. If Relution is going to be installed on the same machine you can skip these steps.

sudo editor /etc/mongod.conf

Find the following section:

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

Comment the bindIp so that it looks like this:

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.

Restart the MongoDB service for the changes to take effect:

sudo systemctl restart mongod.service

Check installation

Verify MongoDB is running as expected:

sudo cat /var/log/mongodb/mongod.log

You should see a message similar to:

... NETWORK  [initandlisten] waiting for connections on port 27017

You can now use the command line utility to connect to the MongoDB instance.

mongo

Type exit to disconnect again.

Firewall configuration

If you’re going to install Relution on another machine, you need to open port 27017 on this machine, so Relution can talk to MongoDB. If Relution is going to be installed on the same machine you can skip these steps.

Replace ADDRESS with the IP address and netmask of the machine or network you want to grant access to this MongoDB instance. Examples: Use 192.168.0.1/32 to grant access to the machine with the IP address 192.168.0.1. Use 192.168.0.0/24 to grant access to any machine in the IP address range 192.168.0.x. When in doubt, consult your network administrator.
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="###ADDRESS###" port protocol="tcp" port="27017" accept'
sudo firewall-cmd --reload