Fancy UI

All About Crazy IT Stuff

Installing MongoDB 2.0 on Ubuntu 11.10

with 13 comments

Ubuntu 11.10 ships with an older version of MongoDB, in this article I’m going to show how to install properly the latest version MongoDB which the 2.0.1.

First you have to download the 32bit or 64bit Linux binaries from here and unzip the contents to /usr/local.

cd /tmp
sudo tar -zxf /tmp/mongodb-linux-i686-2.0.1.tgz -C /usr/local

Then you need to configure some symbolic links.

sudo ln -s /usr/local/mongodb-linux-i686-2.0.1 /usr/local/mongodb
sudo ln -s /usr/local/mongodb/bin/bsondump /usr/local/bin/bsondump
sudo ln -s /usr/local/mongodb/bin/mongo /usr/local/bin/mongo
sudo ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongod
sudo ln -s /usr/local/mongodb/bin/mongodump /usr/local/bin/mongodump
sudo ln -s /usr/local/mongodb/bin/mongoexport /usr/local/bin/mongoexport
sudo ln -s /usr/local/mongodb/bin/mongofiles /usr/local/bin/mongofiles
sudo ln -s /usr/local/mongodb/bin/mongoimport /usr/local/bin/mongoimport
sudo ln -s /usr/local/mongodb/bin/mongorestore /usr/local/bin/mongorestore
sudo ln -s /usr/local/mongodb/bin/mongos /usr/local/bin/mongos
sudo ln -s /usr/local/mongodb/bin/mongosniff /usr/local/bin/mongosniff
sudo ln -s /usr/local/mongodb/bin/mongostat /usr/local/bin/mongostat

All you need to do now is to setup the Linux service which will be used to start MongoDB server, to do so download this script from here.

sudo mv mongod /etc/init.d/mongod
sudo chmod +x /etc/init.d/mongod

After this, you’ll need to create a new system user ‘mongodb’ and prepare some folders.

sudo useradd mongodb
sudo mkdir -p /var/lib/mongodb
sudo mkdir -p /var/log/mongodb
sudo chown mongodb.mongodb /var/lib/mongodb
sudo chown mongodb.mongodb /var/log/mongodb

And finally you need to activate you MongoDB service’s by adding it to your system’s run-level. That way the service will startup during the boot sequence and stop nicely during the OS shutdown procedure.

sudo update-rc.d mongod defaults

That’s all, now you have a cleanly installed MongoDB on your server.


Written by imrabti

October 31, 2011 at 8:23 pm

Posted in MongoDB, Ubuntu

Tagged with , ,

13 Responses

Subscribe to comments with RSS.

  1. Very nice tutorial…. but I dont want to start the mongodb-server at boot time instead I would like to start / stop it whenever I really need it… How can I do that..?

    Thanks once again …


    November 8, 2011 at 7:26 am

    • The last command in the article make mongod start automatically. Use the following command to remove it from the list of services that start automatically ‘ update-rc.d -f mongod remove’

      To start it manually use : ‘service mongod start’
      To stop it manually use : ‘service mongod stop’


      November 8, 2011 at 3:00 pm

  2. Perfect ! Thanks.


    November 10, 2011 at 9:59 pm

  3. i follow this tutorial and i think it’s great, i choose to start the service manually, so i don’t do last step, but i notice something stange: the first time i type “sudo service mongod start” the service fails to start, so i try it again “sudo service mongod start” and it works perfectly, simthing strange.

    So i need to type “sudo service mongod start” TWICE


    December 3, 2011 at 4:38 pm

    • I got the error message the first time I started mongod too, but it still started and worked as it should do. Maybe it checks to see if its running too early.


      April 11, 2012 at 11:11 am

  4. Wow, nice primer on how to do a clean non-apt-get Debian install.

    I’m always torn between waiting for a service to get into the repositories and getting the latest. In this case I have to have the latest but my question is what you would do to upgrade or switch back when 2.0.1 gets into the repositories. Maybe your answer will make me less torn in the future?


    December 4, 2011 at 11:50 pm

    • All you have to do is remove the mongod service using the command ‘update-rc.d -f mongod remove’ and deleting the ‘mongod’ file from ‘/etc/init.d’, after this you sould all the link you created on ‘/usr/local/bin’ and finally delete both ‘/usr/monpdb’ and ‘/mongodb-linux-i686-2.0.1’.

      Mongodb databases are stored on ‘/data’ so once you install the version from repository it’ll use the same path and your data are conserved.

      Normally the repository version will never get the latest version, also using this manual install it is very easy to update, all you have to is to change links to the new mongodb folder and voila.


      December 5, 2011 at 7:03 am

  5. hosts the debian packages mongodb-10gen and mongodb-10gen-unstable. mongodb-10gen is the current 2.0.1 version.


    December 5, 2011 at 4:45 pm

  6. […] Google is your friend!  I did find one particular blog post that was worth mentioning to setup MongoDB on Ubuntu 11.10 which was a big help. Share this:FacebookLinkedInDiggRedditEmailPrintLike this:LikeBe the first to […]

  7. Wow, nice article. Nice explanations and perfect steps for non-apt-get Debian install.
    Thanks for saving my day.

    Pankaj Sonawane

    April 17, 2012 at 9:58 am

  8. I am curious to find out what blog platform you have been working with?
    I’m having some minor security problems with my latest site and I would like to find something more safeguarded. Do you have any solutions?

  9. constantly i used to read smaller articles which also clear
    their motive, and that is also happening with this article which I am reading here.

  10. It’s remarkable in support of me to have a web site,
    which is good for my experience. thanks admin


    October 8, 2014 at 10:07 am

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: