Install Mongodb on AWS EC2 ubuntu 18.04

Mongodb is one of the leading Nosql database. It is an open source document based nosql database developed on top of C++ language. In this post we will be explaining step by step process to install mongodb on AWS EC2 ubuntu 18.04 instance. This article may stand true for digital ocean droplets and linode vm’s as well.

We are assuming you have already connected on to your server through ssh. In case you do not know how to ssh into your AWS EC2 then go through this url to know you do not know how to connect to AWS EC2 through ssh.

Step 1: Key Download

Download key to authenticate packages

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Step 2: Add Repo

Use below command to add mongodb repo. We will be downloading community version 4.0.

sudo echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Step 3: Update Package list

Use below command to update package list.

sudo apt-get update
Step 4: Install mongodb

Use below command to install mongodb.

sudo apt-get install -y mongodb-org
Step 5: Start Mongodb

Use below command to start mongodb.

sudo service mongod start
Step 6: Verify the installation

To verify mongo daemon has successfully started or not you can check the contents of the log file at /var/log/mongodb/mongod.log

tail -n 50 /var/log/mongodb/mongod.log

If you find a line somewhere reading as – [initandlisten] waiting for connections on port 27017  . Then its confirmed that mongodb is successfully installed and running.

Please follow and like us:
20
2 Comments

Add a Comment

Your email address will not be published. Required fields are marked *