Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
AWS

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/

create new EC2 instance on Amazon Linux AMI platform

SSH into the instance

on the terminal, create the file

vi /etc/yum.repos.d/mongodb-org-4.0.repo

press i into insert mode, copy&past the following to the created file

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

enter :wq to save content and exit insert mode

Then install MongoDB by following command

sudo yum install -y mongodb-org

Start mongoDB server

sudo service mongod start

Verify MongoDB is running

cat /var/log/mongodb/mongod.log

You should find [initandlisten] waiting for connections on port <port> somewhere in the log file.

Stop MongoDB server

sudo service mongod stop

Restart MongoDB server

sudo service mongod restart

Start a MongoDB shell

mongo --host 127.0.0.1:27017

Stop and uninstall MongoDB

sudo service mongod stop
sudo yum erase $(rpm -qa | grep mongodb-org)
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment