Reading Time: 3 minutes

MongoDB is a NoSQL database intended for storing large amounts of data in document-oriented storage with dynamic schemas. NoSQL refers to a database with a data model other than the tabular format used in relational databases such as MySQL, PostgreSQL, and Microsoft SQL. MongoDB features include: full index support, replication, high availability, and auto-sharding.

Preflight Check

  • A Liquid Web Core Managed CentOS 7 node.
  • We are logged in as the root user.

Step #1: Add the MongoDB Repository

First, we will use the vim text editor to create a new repo file for MongoDB. For a refresher on editing files with vim see: New User Tutorial: Overview of the Vim Text Editor

root@host:~# vim /etc/yum.repos.d/mongodb.repo

Next, add the following information to the file you've created, using i to insert:

name=MongoDB Repository

Then save and exit vim using the command :wq.

Step #2: Install MongoDB

As a matter of best practice we will update our packages.

root@host:~# yum -y update

At this point, installing MongoDB is as simple as running this command.

root@host:~# yum install -y mongodb-org

Step #3: Configure MongoDB


Many Linux OSes confine the amount of system resources which a process can use. These limits sometimes can negatively effect the operation of MongoDB, and should be adjusted accordingly. The ulimit setting for CentOS 7 can be modified using the following command.

root@host:~# ulimit -n <value>

Additionally, CentOS 7 enforces a distinct max process limitation using, nproc, which overrides the ulimit settings. This nproc value is defined in this configuration file


To configure a nproc value, use vim to create a file called 99-mongodb-nproc.conf.

root@host:~# touch /etc/security/limits.d/99-mongodb-nproc.conf

Now, add the new soft nproc and hard nprocvalues to increase the process limit.

-f (file size): unlimited
-t (cpu time): unlimited
-v (virtual memory): unlimited [1]
-l (locked-in-memory size): unlimited
-n (open files): 64000
-m (memory size): unlimited [1] [2]
-u (processes/threads): 64000

Step #4: Start MongoDB

In MongoDB 4.4 and above, a startup error is seen if the ulimit value for number of open files is under 64000.

To run and manage the mongod process, we will use our OSes default init system. Newer versions of Linux typically use systemd (systemctl), and older versions use System V init (service). To determine which init system the platform uses, run the following command.

root@host:~# ps --no-headers -o comm 1

 Init Systems

  • Start Mongodb Using Systemd (Systemctl)
  • Start Mongodb Using System V Init (service)

1. Start the mongod process.

root@host:~# systemctl start mongod

If you receive an error like:

Failed to start mongod.service: Unit mongod.service not found.

Run the following command.

root@host:~# systemctl daemon-reload

Then, run the start command above again.

2. Verify MongoDB has started.

To verify the mongod process has started successfully, issue the following command.

root@host:~# systemctl status mongod

To ensure MongoDB starts after a system reboot, issuing the following command.

root@host:~# systemctl enable mongod

Step #5: Check MongoDB Status & Info

Check MongoDB Service Status

systemctl status mongod

Summary List of Status Statistics (Continuous)


Summary List of Status Statistics (5 Rows, Summarized Every 2 Seconds)

mongostat --rowcount 5 2

Enter the MongoDB Command Line


By default, running this command will look for a MongoDB server listening on port 27017 on the localhost interface.

If you’d like to connect to a MongoDB server running on a different port, then use the --port option. For example, if you wanted to connect to a local MongoDB server listening on port 22222, then you’d issue the following command:

mongo --port 22222

Shutdown MongoDB

systemctl stop mongod


MongoDB is an excellent NoSQL solution for many types of projects. It is resilient, robust, and durable document database that is designed for ease of development and scaling. 

Our talented Support Teams are full of experienced technicians and administrators who have intimate knowledge of multiple web hosting technologies, especially those discussed in this article. We are always available to assist with any issues related to this article, 24 hours a day, 7 days a week 365 days a year.

If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server or a Dedicated server owner and you are uncomfortable with performing any of the steps outlined, we can be reached via phone @800.580.4985, a chator support ticket to assisting you with this process.

Avatar for David Singer

About the Author: David Singer

I am a g33k, Linux blogger, developer, student, and former Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article