Installation of MongoDB in Pseudo Distributed cluster ( Linux )

Hi MongoDBlistners,

This material is providing you some information about the installation of MongoDB pseudo cluster in a Linux environment. Just ten step will give you a mongodb pseudo cluster in your machine. Install MongoDB and start processing it.

Mongodb_pseudo_cluster_Linux

What is mongod ?
mongod is the primary daemon process for the MongoDB system. It handles data requests, manages data format, and performs background management operations. This document provides a complete overview of all command line options for mongod. These options are primarily useful for testing purposes.

1. Download
Use below link to download MongoDb or if you want to download the latest version of MongoDB then check its official web Site

$wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.8.tgz

2. Extract MongoDb
After downloading untar mongodb use the below command to untar it.
$tar -zxvf mongodb-linux-x86_64-2.4.8.tgz

3. Reload local package database
We need to update the apt-get in your system because we will use it to download the mongodb dependencies so lets update it using below command
$sudo apt-get update

4. Install the mongodb server
After updating apt-get, we need to install mongodb server. Use below command to install mongodb-server using software center
$sudo apt-get install mongodb-server

5. Create a directory for MongoDB
Now we need to create some directories which are need for mongodb. This folder created will be used by mongodb to store the physical block.
$sudo mkdir /data
$sudo mkdir /data/db

6. Change the mod of permission for mongodb
Now change permissions for the folder that are created manually.
$sudo chmod -R 777 /data/*

7. Enter in to mongodb folder
Now lets enter in to mongodb to start and to process mongodb
$cd mongodb-linux-x86_64-2.6.0

8. Start the mongod and mongo
Now lets start mongodb use the below command. First command “bin/mongod” will start mongodb daemon. Second command “bin/mongo” will open you the mongodb shell.
$bin/mongod
$bin/mongo
or
$mongo localhost:27017

—————————————————————————————————————————————-

BASIC CONCEPTS
———————

Process Queries in MongoDb
switch to given database use <database>
List the available databases show dbs
List the available collections show collections
List the available commands and help help
Create a Collection db.createCollection(“datadotz”, { size: 1048576 } )
Show the collections show collections
Delete a Collection db.getCollection(“datadotz”).drop()
To know what database we are using db
Inserting into a database db.employee.insert({pid:’1′,name:’alex’,drug:’avil’,tot_amt:100})
db.employee.insert({pid:’2′,name:’gowtham’,drug:’Paracetamol’,tot_amt:200})
db.employee.insert({pid:’3′,name:’Ram’,drug:’metacin’,tot_amt:300})
db.employee.insert({pid:’4′,name:’saravanan’,drug:’metacin’,tot_amt:400})
db.employee.insert({pid:’5′,name:’senthil’,drug:’Avil’,sex:’male’,tot_amt:500})
db.employee.insert({pid:’6′,name:’siva’,drug:’avil’,tot_amt:600})
Display all the details in the database db.test.find()

———————————-

Article written by DataDotz Team

DataDotz is a Chennai based BigData Team primarily focussed on consulting and training on technologies such as Apache Hadoop, Apache Spark , NoSQL(HBase, Cassandra, MongoDB), Search and Cloud Computing.

Note: DataDotz also provides classroom based Apache Kafka training in Chennai. The Course includes Cassandra , MongoDB, Scala and Apache Spark Training. For more details related to Apache Spark training in Chennai, please visit http://datadotz.com/training/