How To Install MongoDB Community Edition

This article describes how to install MongoDB Community Edition on CentOS Linux. The same installation applies to RedHat Linux versions.

Versions:
Operating System: CentOS Linux 7 – 64bit
MongoDB: MongoDB Community Edition 3.2

If you want to install Sharded Cluster you may want to read below article.

Deploy Sharded Cluster with Keyfile Access Control on Red Hat Enterprise Linux or CentOS Linux

Step 1: Create a User For Administration

Step 2: Configure yum For Installation

You can also install directly with .rpm. You can download packages at https://www.mongodb.com/download-center#community. For YUM configuration, file mongodb-org-3.2.repo is created under /etc/yum.repos.d and set as follows.

Step 3: Install MongoDB with mongodb user

Step 4: Start MongoDB

MongoDB is enabled using the mongod process. The MongoDB service is started as follows.

Step 5: Configure mongod

It is configured as follows to automatically start the mongod service when the system restarts.

Where is MongoDB Data Files and Log Files?

By default, MongoDB stores data files in the /var/lib/mongo path and log files in /var/log/mongodb. To change these values, it is necessary to start the mongod process with the appropriate parameters or to use a configuration file.