How to Install MongoDB on Ubuntu 12.04 LTS

MongoDB is the leading NoSQL database. It has become very popular with modern web applications because of its support for JSON-style documents with dynamic schemas. This tutorial will help you install MongoDB on your Ubuntu 12.04 LTS.

First, ssh into your Pod as root. In this example, the Pod’s hostname is mongopod. Once logged in, running these four commands will install MongoDB for you:

root@mongopod:~# apt-key adv --keyserver --recv 7F0CEB10

root@mongopod:~# echo "deb dist 10gen" | tee -a /etc/apt/sources.list.d/10gen.list

root@mongopod:~# apt-get -y update

root@mongopod:~# apt-get install mongodb-10gen

If successful, the last line of output should read akin to:

mongodb start/running, process 1305

This shows that MongoDB was successfully installed and is currently running (in this example) as process 1305. Your Pod has been configured to automatically start the mongodb process on boot.

You can verify the process is running by looking in the process list for a process containing the string “mongo”, example:

root@mongopod:~# ps aux | grep mongo

The output should show a process similar to:

mongodb 1305 3.6 1.9 349060 39588 ? Ssl 21:18 0:05 /usr/bin/mongod –config /etc/mongodb.conf

Next, you might want to try running the “mongo” command to execute the MongoDB shell.

Matthew McCaffrey

Leave a Reply