Installing MongoDB 2.0 on Ubuntu 11.10

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 and unzip the contents to /usr/local.

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

Then you need to configure some symbolic links.

01 sudo ln -s /usr/local/mongodb-linux-i686-2.0.1 /usr/local/mongodb
02 sudo ln -s /usr/local/mongodb/bin/bsondump /usr/local/bin/bsondump
03 sudo ln -s /usr/local/mongodb/bin/mongo /usr/local/bin/mongo
04 sudo ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongod
05 sudo ln -s /usr/local/mongodb/bin/mongodump /usr/local/bin/mongodump
06 sudo ln -s /usr/local/mongodb/bin/mongoexport /usr/local/bin/mongoexport
07 sudo ln -s /usr/local/mongodb/bin/mongofiles /usr/local/bin/mongofiles
08 sudo ln -s /usr/local/mongodb/bin/mongoimport /usr/local/bin/mongoimport
09 sudo ln -s /usr/local/mongodb/bin/mongorestore /usr/local/bin/mongorestore
10 sudo ln -s /usr/local/mongodb/bin/mongos /usr/local/bin/mongos
11 sudo ln -s /usr/local/mongodb/bin/mongosniff /usr/local/bin/mongosniff
12 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.

1 wget
2 sudo mv mongod /etc/init.d/mongod
3 sudo chmod +x /etc/init.d/mongod

After this, you’ll need to create a new system user ‘mongodb’ and prepare some folders.
1 sudo useradd mongodb
2 sudo mkdir -p /var/lib/mongodb
3 sudo mkdir -p /var/log/mongodb
4 sudo chown mongodb.mongodb /var/lib/mongodb
5 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.

1 sudo update-rc.d mongod defaults

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

One thought on “Installing MongoDB 2.0 on Ubuntu 11.10

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