Skip to content

Instantly share code, notes, and snippets.

@comerford
Created May 6, 2013 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comerford/5525099 to your computer and use it in GitHub Desktop.
Save comerford/5525099 to your computer and use it in GitHub Desktop.
How to make oplogMainRowCount appear on MongoDB
// delete oplog, crete new and empty
testReplSet:PRIMARY> use local
switched to db local
testReplSet:PRIMARY> db.oplog.rs.drop()
true
testReplSet:PRIMARY> db.createCollection("oplog.rs", {capped:1, size: 2*1024*1024, autoIndexId:false})
{ "ok" : 1 }
// run the command to get the fields
testReplSet:PRIMARY> db.getReplicationInfo()
{
"logSizeMB" : 2,
"usedMB" : 0,
"errmsg" : "objects not found in local.oplog.$main -- is this a new and empty db instance?",
"oplogMainRowCount" : 0
}
// insert anything, to populate the oplog
testReplSet:PRIMARY> use test
switched to db test
testReplSet:PRIMARY> db.foo.insert({"a" : 1})
// and now the extra fields are gone
testReplSet:PRIMARY> db.getReplicationInfo()
{
"logSizeMB" : 2,
"usedMB" : 0.01,
"timeDiff" : 0,
"timeDiffHours" : 0,
"tFirst" : "Mon May 06 2013 14:17:09 GMT+0100 (IST)",
"tLast" : "Mon May 06 2013 14:17:09 GMT+0100 (IST)",
"now" : "Mon May 06 2013 14:17:11 GMT+0100 (IST)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment