Understanding and analyzing oplogs
Oplog is a special collection and forms the backbone of the MongoDB replication. When any write operation or configuration changes are done on the replica set's primary, they are written to the oplog on the primary. All the secondary members then tail this collection to get the changes to be replicated. Tailing is synonymous to tail command in Unix and can only be done on a special type of collection called capped collection. Capped collections are fixed size collections which maintain the insertion order just like a queue. When the collection's allocated space becomes full, the oldest data is overwritten. If you are not aware of capped collections and what tailable cursors are, please refer to Creating and tailing a capped collection cursors in MongoDB in Chapter 5, Advanced Operations for more details.
Oplog is a capped collection present in the non-replicated database called local. In our previous recipe, we saw what a local
database is and what collections...