Skip to content

Instantly share code, notes, and snippets.

@jiehan1029
Created September 4, 2018 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiehan1029/e2d848012cdd5fe6774c56c96e85f606 to your computer and use it in GitHub Desktop.
Save jiehan1029/e2d848012cdd5fe6774c56c96e85f606 to your computer and use it in GitHub Desktop.
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