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
http://www.mongodb.org/downloads
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.
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongodb.log                    
logappend=true
nojournal=true                                                                                 

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:
/bin/mongo                                                                                  

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.

10 comments:

  1. Hello there,

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

    ReplyDelete
  2. i got error in
    path_to_conf_file

    ReplyDelete
  3. Anyone help me plz thanks in advance

    ReplyDelete
  4. Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.

    Best AWS Training in Chennai | Amazon Web Services Training in Chennai

    ReplyDelete
  5. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    python training in velachery | python training institute in chennai



    ReplyDelete
  6. I appreciate that you produced this wonderful article to help us get more knowledge about this topic. I know, it is not an easy task to write such a big article in one day, I've tried that and I've failed. But, here you are, trying the big task and finishing it off and getting good comments and ratings. That is one hell of a job done!

    Java training in Chennai | Java training in USA | Java training in Kalyan nagar

    Java training in Indira nagar | Java training in Rajaji nagar

    ReplyDelete
  7. I was recommended this web site by means of my cousin. I am now not certain whether this post is written through him as nobody else recognise such precise about my difficulty. You're amazing! Thank you!

    Data Science Training in Chennai | Data Science training in anna nagar

    Data Science training in chennai | Data science training in Bangalore

    Data Science training in marathahalli | Data Science training in btm layout

    ReplyDelete
  8. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here.
    Devops Training in Chennai | Devops Training Institute in Chennai

    ReplyDelete