Reputation: 1211
I want to see oplog so I have started MongoDB with as suggested in here
mongod --master --port 8888 --dbpath ...
But when I run
>db.oplog.rs.find()
It returns nothing
When I run
>db.oplog.rs.stats()
returns error
{
"ok" : 0,
"errmsg" : "ns not found"
}
I have also tried these commands with '>use local'. I see same results.I am planning to read it using java oplog watcher API. But not able to get it. What am I missing.How to see oplog.
Upvotes: 5
Views: 15319
Reputation: 12904
"oplog.rs" is found in the "local" database. So, you can try something like:
use local
db.oplog.rs.find()
or from a different database:
db.getSiblingDB("local").oplog.rs.find()
Upvotes: 12
Reputation: 43884
Ok so it isn't replica set when you use --master
it is actually the deprecated master-slave replication which got me thinking that maybe it is just a different name:
> show collections
oplog.$main
startup_log
> db.oplog.$main.find()
{ "ts" : Timestamp(1394104629, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104643, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104653, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104663, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104673, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104683, 1), "op" : "n", "ns" : "", "o" : { } }
{ "ts" : Timestamp(1394104693, 1), "op" : "n", "ns" : "", "o" : { } }
Turns out I was right.
Upvotes: 2