MongoDB-3.6 Community Edition Installation

In this post, I am going to use yum to install MongoDB-3.6 from MongoDB’s official repository. First we start with adding a .repo file at location /etc/yum.repos.d/. You can name the file anyway you wish but the extension has to be .repo.

vim /etc/yum.repos.d/mongodb.repo

mongodb installation

Paste the follow code into the .repo file you created, save and exit. You can change 3.6 to the version you want. For instance, 3.4 or 3.2.

name=MongoDB Repository

mongodb installation

Check if the repository is successfully added.

yum repolist

mongodb installation

Start installing MongoDB.

yum install mongodb-org

mongodb installation

The functionality of each installed packages.
mongodb installation

After installation, let’s check the initial status of mongod.

systemctl status mongod

mongodb installation

For more usage of systemctl, please refer: CentOS7 Systemctl Cheat Sheet

Mongod is enabled initially. If the service is not enabled, use command below to enable and start the service.

systemctl enable mongod
systemctl start mongod

mongodb installation

Check the version of mongod.

mongo -version

mongodb installation

Locations related to Mongodb.

  1. /etc/mongod.conf; config file of mongod.
  2. /var/log/mongodb/; log file of mongod.
  3. /var/lib/mongo/; db path of mongod, all data files are store here.

mongodb installation

Connect to mongod.


mongodb installation

MongoDB Enable User Login Authentication
Setup MongoDB Replication With Arbiter Environment

Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux