Installing MongoDB on an EC2 Linux instance

This applies to Fedora/CentOS/RedHat distributions of Linux.

Log in to the instance is as root

Add the 10gen MongoDB repository for yum, by creating the file /etc/yum.repos.d/10gen-mongodb.repo

For 64-bit version of MongoDB, add the following

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0

For 32-bit version of MongoDB, add the following

[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/i686
gpgcheck=0

Install MongoDB by running the following command

yum install mongo-10gen mongo-10gen-server

Modify the file /etc/mongod.conf Change the location of DB, logs files, ports as necessary

logpath=/var/log/mongo/mongod.log
port=27017
dbpath=/var/lib/mongo

If you have changed the location of the db or log files, make sure that mongod has write permissions at the new locations. If not assign persmission

chown mongod:mongod /newlocation/mongodbfiles

Start MongoDB server

service mongod start
or
/etc/init.d/mongod start

To start MongoDB on server reboot

chkconfig --levels 235 mongod on
Advertisements

2 thoughts on “Installing MongoDB on an EC2 Linux instance

  1. Pingback: Now You Know What I Did Last Weekend: @redditJava | adadeh

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s