AWS

How to Install MongoDB on AWS

MongoDB is used to store no SQL data structure, which means that you can store a document without any structure and can have any number of fields. MongoDB is an In-memory data store which means that all the data stored in MongoDB is in the memory, which can be easily accessible. We can install MongoDB on AWS using an EC2 virtual machine to use it more efficiently. This post will teach you the installation process of MongoDB on AWS.

Let’s start with how to install MongoDB on AWS

Install MongoDB on AWS EC2

To install MongoDB on AWS, you need to create an EC2 instance, and for that, simply click on the “Launch Instance” button from the EC2 dashboard:

Type the name for the instance and select the machine Image for your virtual machine:

Now select the instance and create a key pair for the instant connection and then simply click on the “Launch Instance” button to create an EC2 instance:

Once the EC2 instance is created you need to connect to your virtual machine for that simply select the EC2 instance and click on the “Connect” button:

On the Connection, page select the “SSH client” and copy the command for the connection:

Now paste the command on the Command prompt or PowerShell and change the key pair path from your PC:

After you are connected to the EC2 virtual machine you need to use the following command to get the updates:

sudo apt-get update

This command will get your virtual all the updates:

After the updates are done now you need to install the key server for that use the following command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

This command will install the key server which is required to install the mongo dB:

After the key server there is one more requirement that can be installed using the following command:

echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.6 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

This command will get the location from where the MongoDB can be installed:

After all the requirements are complete, you can use the following command to install the MongoDB:

sudo apt-get install -y mongodb-org

This command is used to install the MongoDB:

After the MongoDB is installed you can look for its version with the following command:

mongod --version

This command will fetch you the version you just installed:

You have successfully installed the MongoDB in AWS:

Conclusion

To install the MongoDB on AWS you need to create an EC2 instance and then connect to your virtual machine. After the connection, you need to install some prerequisites before installing MongoDB. Once everything is in place, you need to install MongoDB with a basic command shown in the article. In the end, verify the installation by simply checking the version of MongoDB.

About the author

Abdul Mannan

I am curious about technology and writing and exploring it is my passion. I am interested in learning new skills and improving my knowledge and I hold a bachelor's degree in computer science.