How to Setup MongoDB Community Server on Azure/AWS

To setup and install MongoDB community server on Azure or AWS, the recommended way is to install using the image available in the cloud marketplaces.  Deploy a MongoDB server running community edition on Ubuntu Server or CentOS Server.

Getting Started


Once your MongoDB server has been deployed, the following links explain how to connect to a Linux VM:



Once connected and logged in, the following section explains how to start using MongoDB 

Using MongoDB Community Server


MongoDB uses the mongo shell to interact with MongoDB


ulimit Considerations


Most Unix-like operating systems limit the system resources that a process may use. These limits may negatively impact MongoDB operation, and should be adjusted. See UNIX ulimit Settings for the recommended settings for your platform.


Starting in MongoDB 4.4, a startup error is generated if the ulimit value for number of open files is under 64000.


Directories on Ubuntu

The data directory /var/lib/mongodb and the log directory /var/log/mongodb are created during the installation.


Directories on CentOS

The data directory /var/lib/mongo and the log directory /var/log/mongodb are created during the installation


By default, MongoDB runs using the mongodb user account. If you change the user that runs the MongoDB process, you must also modify the permission to the data and log directories to give this user access to these directories.


Configuration File

The official MongoDB package includes a configuration file (/etc/mongod.conf). These settings (such as the data directory and log directory specifications) take effect upon startup. That is, if you change the configuration file while the MongoDB instance is running, you must restart the instance for the changes to take effect.


Running MongoDB on Ubuntu:


Running MongoDB on CentOS:

MongoDB Community Server Documentation


Please refer to MongoDB onilne guides on using MongoDB

MongoDB Firewall Ports


MongoDB uses the following default TCP firewall ports:


Port 27017 – The default port for mongod and mongos instances. You can change this port with port or –port.

Port 27018 – The default port for mongod when running with –shardsvr command-line option or the shardsvr value for the clusterRole setting in a configuration file.

Port 27019 – The default port for mongod when running with –configsvr command-line option or the configsvr value for the clusterRole setting in a configuration file.

The links below explain how to modify / create firewall rules depending on which cloud platform you are using.


To setup AWS firewall rules refer to – AWS Security Groups

To setup Azure firewall rules refer to – Azure Network Security Groups


Disclaimer: MongoDB is a registered trademark of MongoDB, Inc and is licensed under SSPL license. No warrantee of any kind, express or implied, is included with this software. Use at your risk, responsibility for damages (if any) to anyone resulting from the use of this software rest entirely with the user. The author is not responsible for any damage that its use could cause.
Andrew Fitzgerald

Cloud Solution Architect. Helping customers transform their business to the cloud. 20 years experience working in complex infrastructure environments and a Microsoft Certified Solutions Expert on everything Cloud

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x