Pages

Search This Blog

Friday, February 13, 2015

[Mongodb] M-102 Week 4 Assignments


# starting as a standalone server for problem 1:
mongod --dbpath 1 --port 27001 --smallfiles --oplogSize 50
mongo --port 27001 --shell week4.js
> homework.init()
> homework.a()

result : 5001

rs.init()
use week4
> db.foo.find()
> homework.b()

answer: 5002

mongo --port 27002 week4.js --shell
> homework.c()

result : 5

rs.help()
> rs.stepDown(300)
cfg = rs.conf()
cfg.members.shift()
rs.reconfig(cfg)
homework.d()

answer: 6

> // expect to get back false as we are not primary
> db.isMaster().ismaster
false
> db.oplog.rs.find()
> db.oplog.rs.stats()
db.oplog.rs.find().sort({$natural:1}).limit(1).next().o.msg[0]

answer: R
 

No comments: