MongoDB
Understanding MongoDB Oplog
Deep dive into MongoDB operation log
MongoDB, similar to other databases operates using a transaction log internally. In MongoDB’s case, it is called oplog
. I have been looking into the oplog to understand the operations a bit more so as to process them for data ingestion. This post documents my learnings.
Oplog is a log of every internal operation used for replication in a MongoDB cluster. In a sharded cluster, each replica set has its own oplog. The oplog in all cases is a capped collection and can be accessed like any other collection in MongoDB. There are two types of operations in MongoDB: commands and data manipulation ops.
Oplog entry structure
Before diving into the oplog commands and values let’s look at how the oplog entry is structured.