Monday, April 20, 2015

M102: MongoDB for DBAs - week 5 answer

Homework 5.1

1) 7

Homework 5.2

Check on 

1) Add an arbiter.
2) Add another data bearing node

Homework 5.3

db.m102.insert([{"a":1},{"b":2},{"c":3}])

Homework 5.4

Check on None of the above.

Homework 5.5

{ force : true }


Monday, April 13, 2015

M102: MongoDB for DBAs - Homework 4.2


Step 1:
You need to run all the replica Set use below command
mongod --dbpath "c://1" --replSet abc --port 27002
mongod --dbpath "c://2" --replSet abc --port 27002
mongod --dbpath "c://3" --replSet abc --port 27003

Step 2:
Note: do close mongo shell, if you have close then reload the data as per step given in homework 4.1

Step 3:
Run on mongo shell
rs.initiate()
then
use replication
then db.foo.find() to check data

then run

homework.b()
you will get your answer as 5002



Saturday, April 11, 2015

Answer For Week 4 for mongodb

All the Answer for week 4 mongodb 102 course                            

1) Homework 4.1 :  answer is 5001
2) Homework 4.2: answer is  5002
3) Homework 4.3: answer is 5
4) Homework 4.4 : answer is 6
5) Homeowrk 4.5 : answer is R

M102: MongoDB for DBAs : Homework 4.1

Step 1:
Download Handout

Step 2:
Unpack replication.js from the Download Handout zip file.

Step 3:
You need to create 3 different directory for 3 replica set

on windows:
you can create diretory as 1 , 2 and 3 in c drive

you can start mongod instance using
mongod --dbpath 1 --port 27001 --smallfiles --oplogSize 50


Step 4:
you can import replication.js using

mongo --port 27001 --shell replication.js


Step 5:
Once the shell is up
you can write
homework.init();

then homework.a();


Above query will give your answer as
5001


Tuesday, April 7, 2015

M102: MongoDB for DBAs - homework 3.4

Wiredtiger is new storage engine, it come with following feature
1) Data compression
2) Document level locking.

Monday, April 6, 2015

M102: MongoDB for DBAs - Homework 3.3

Step 1:
Download the handout


Step 2:
import products.json using mongo import utility


mongoimport -d pcat -c products --drop products.json

Step 3:
now enter into mongo shell 
use pcat database using 
use pcat

Step 4:
add index on for field using 
db.products.ensureIndex({for:1});

Step 5:
now create and run the query you will  get answer as

q1) 4
q2) 4
q3) yes

M102: MongoDB for DBAs - Homework 3.2

Step 1:
In mongo shell run
homework.b()

operation will be very slow, you need to figure out the same

Step 2:
open another prompt
type below command in command prompt
 mongo --shell localhost/performance performance.js

note: do not close first shell

Step 3:
Using db.currentOp() you can check current running operation and using
db.killOp(?) you can kill the running operation

? - will be operation id
{ opid}

step 4:
now run homework.c()

you will get your answer as 12