Stack Engineer

Install MongoDB on CentOS

MongoDB is an document-based NoSQL database. It provides high performance, high availability, and scaling. Data is stored as a document record made up of JSON objects.

Step 1 - Add the MongoDB Repo

Create a new file called /etc/yum.repos.d/mongodb-org-3.4.repo and add the following text to it.

name=MongoDB Repository

Step 2 - Install MongoDB

Run the following commands to install MongoDB and add an exception to SELinux to allow it to run with its default configuration.

sudo yum update
sudo yum install mongodb-org
sudo semanage port -a -t mongod_port_t -p tcp 27017

Step 3 - Start MongoDB

Start MongoDB and set it to automatically start when the system boots.

sudo systemctl start mongod
sudo systemctl enable mongod