Showing posts with label mongodb dba. Show all posts
Showing posts with label mongodb dba. Show all posts

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

M102: MongoDB for DBAs - Homework 3.1

Step 1:
Download the handout and load in mongodb using

mongo --shell localhost/performance performance.js


then run

homework.init()


you need to add index on field
active and timestamp

Step 2:
Add Index using

db.sensor_readings.ensureIndex({tstamp:1, active:1})

Step 3:
run homework.a()

you will get answer as 6

if anything wrong you will get a message to try better index

Sunday, March 29, 2015

M102: MONGODB FOR DBAS - Homework 2.3

Step 1:
execute below query in mongo shell
> db.products.find({"limits.voice":{$exists:1}}).count()

you will get your answer as 3

M102: MONGODB FOR DBAS - Homework 2.2


Step 1:
Now you need to add product in products collection

you  need to update the id
_id : ObjectId("507d95d5719dbef170f15c00")


with following

term_years to  3
over_rate  for sms in limits to 0.01 from 0


Execute below Query in mongoshell

var temp = db.products.findOne({_id:ObjectId("507d95d5719dbef170f15c00")})

temp.term_years = 3

db.products.update({_id:temp._id},temp)

temp.limits.sms.over_rate = 0.01

db.products.update({_id:temp._id},temp)








Check your answer:

by executing homework.b()

you will get your answer as
0.050.019031


M102: MONGODB FOR DBAS - homework 2.1

Step 1:
Download the handout from

you will see homework2.js








Step 2:
import homework2.js
using
mongo --shell pcat homework2.js

Step 3:
on mongo shell type
>homework.a()

you will get your answer as 3.05


M102: MONGODB FOR DBAS - Homework 1.4

Step 1:
Check all the query in mongodb shell

Step 2:
you will observe that it is giving sorted result for


M102: MONGODB FOR DBAS HOMEWORK - HOMEWORK 1.3

Step 1:
> use pcat

Step 2:
> db.products.find({'brand':'ACME'})


Saturday, March 28, 2015

M102: MongoDB for DBAs - Week 1 - Homework 1.2

Step 1:

Download the products.json

Step 2:

Import products.json using below command
mongoimport -d pcat -c products --type json --file C:\products.json





Step 3:

execute below steps
> use pcat
> db.products.find({type:"case"}).count()

Answer you will get is 3


M102: MongoDB for DBAs homework 1.1

Step 1:
Execute Mongo  Command   db.isMaster().maxBsonObjectSize in shell
you will get output as


Answer is 16777216