Here are the steps to install MongoDB on an Amazon Linux EC2 Server Instance. FYI The prepackaged YUM Amazon package does not work. Don’t install without a new repo file.

mongodb-standard-logo-565

Do the following commands in a Putty terminal.

sudo chmod 2775 /etc/yum.repos.d

Using Sublime create a text file call mongodb-org-2.6.repo with the follow and using Filezilla updload it to /etc/yum.repos.d directory.

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

Do the following commands:

sudo yum install -y mongodb-org
sudo service mongod start
sudo chkconfig mongod on # this turns on auto start on reboot

This process is further explained at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/

Note:

On a small system you will also need to do the following:

chmod 664 mongod.conf

Then edit the /etc/mongod.conf file and add the follow lines to the :storage block to allow small file blocking.

storage:
   mmapv1:
      smallFiles: true

Then start the service with:

mongod -f /etc/mongod.conf # this checks the config file