Friday, January 25, 2013

MongoDB Installation: Standalone Mode

"Mongo" is a short for "Humongous" meaning "Huge".
By the name it goes that, MongoDB is a database phenomenal at dealing with "huge" piles of data.

As per the MongoDB Documentation,
"MongoDB is a scalable, high-performance, open source NoSQL database."

Installing MongoDB in standalone is guileless. It is also achievable using apt-get command in case of Linux. This post is for you if you wish to know what configuration files are used in MongoDB and if you intend to go a longer way rather than just a standalone installation and a casual try out of MongoDB.

Tested On
I have tested the following steps on Ubuntu 10.04 and MongoDB 2.2.2. 

Steps of Installation Step 1: Every version of MongoDB setups comes in two flavors:
  • 32-bit
  • 64-bit
The 32-bit builds run on both 32 and 64-bit machines while 64-bit build runs only on the 64-bit machines. However, as per the MongoDB manual,
"32-bit builds are limited to around 2GB of data. In general you should use the 64 bit builds. The 32 bit binaries are ok for replica set arbiters and mongos but not for production mongod's."

So it would be good to figure out the machine configuration before deployment.
Run the following command to know your machine
uname -m                                                                                         

it would return "i686" for 32 bit machines and "x86_64" for 64 bit machines.

Step 2: According to the Step 1 results download the setup from
Untar the downloaded setup using 

tar  -zxvf  location_of_setup                                                             

Step 3: MongoDB requires 2 directories for it's functioning. They are:
1. Directory for storing the logs
2. Another directory for storing the data i.e. dbpath (by default /data/db)
You can use any suitable location on your machine to create these directories. For example, here we'll be taking
Log Directory: /var/log/mongodb
DBPath: /var/lib/mongodb

Create the above 2 directories as below:
mkdir /var/lib/mongodb
mkdir /var/log/mongodb           

Change their permissions as below:
sudo chmod -R 777 /var/lib/mongodb
sudo chmod -R 777 /var/log/mongodb

Change their ownership to the user (root or non-root) as below:
sudo chown groupName:userName /var/lib/mongodb -R
sudo chown groupName:userName /var/log/mongodb -R

Also change the ownership of the directory where mongodb's setup is copied using similar commands as above.

Step 4: Create a conf file (for example "mongod.conf") at a location owned and accessible by the user.

Step 5: Start the MongoD daemon using:
/bin/mongod --config /path_to_conf_file/mongod.conf                  
Step 6: Verify whether the MongoD daemon is running or not using:
sudo netstat -nlp | grep mongod                                                    

 Step 7: Start using mongodb by opening the mongo shell using:

This completes the installation process of MongoDB in standalone mode. In my next post, I'll be catering steps on how to setup a MongoDB Replica Set.


  1. Hello there,

    Thanks for the blog.
    What to tune in MongoDB SERVER after installation ?

  2. Excellent and easy steps.....

  3. Anyone help me plz thanks in advance