Installing MongoDB on CentOS

Create a Repo File

touch /etc/yum.repos.d/mongodb.repo

And append the following to the file.

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

The base URL in the above will change to http://downloads-distro.mongodb.org/repo/redhat/os/i686/ if you need to install Mongo on 32 bit. But then, why would you run Mongo on 32 bit. It is supposed to process humongous amounts of data and 32 bit will be bad choice.

now, go ahed and run this -

sudo yum install -y mongodb-org

Start mongodb

sudo service mongod start

And boom! you are up and running. To verify whether it is has successfully started, you may check the mongodb log

cat /var/log/mongodb/mongod.log | grep 'waiting for connections on'

You should see this line: [initandlisten] waiting for connections on port 27017

Also, it may be a good idea to enable service at the startup.

sudo chkconfig mongod on
# stop and restart
sudo service mongod stop
sudo service mongod restart

Enjoy!

comments powered by Disqus