Interesting devops tech stuff

Pssst… Server Density v2 is coming soon!

Quick MongoDB tip – how far does your oplog go back?

Written by David Mytton

Choosing the right MongoDB oplog size can be difficult, especially if your usage is growing. So here’s quick way to see what the last item in the oplog is. If your down slave or backup is older that this, it won’t be able to resync:

use local
new Date(db.oplog.rs.find().sort({$natural:1}).limit(1).next()["ts"]["t"])

(Taken from this blog post because otherwise it’ll get lost!)

Enjoy this post? You may also like MongoDB Benchmarks

  • Chris

    You can also get the same type of information from the mongodb command:
    db.printReplicationInfo()