liveBook · Manning

Oplog size

As explained in MongoDB 8.0 in Action, Third Edition

Oplog size is the configured storage capacity allocated to a MongoDB replica-set member's oplog.

Oplog size is the configured storage capacity allocated to a MongoDB replica-set member’s oplog. MongoDB creates a default-sized oplog when a member starts unless you specify a size. section 9.1.3

Use replication information to compare capacity, usage, and the available oplog window:

  • configuredLogSizeMB reports the configured capacity, while logSizeMB reports the actual oplog size. section 9.1.3
  • usedMB shows how much capacity contains replication data. section 9.1.3
  • timeDiff and timeDiffHours show the interval between the earliest and latest oplog entries, indicating the available oplog window. section 9.1.3

Inspect the configured capacity

Run db.getReplicationInfo(). An output with configuredLogSizeMB: 4096, logSizeMB: 4096, and usedMB: 4074.63 shows a 4096 MB oplog that is nearly full; timeDiffHours: 176.43 indicates the represented time span.

Listing 9.3 A single document from the oplog collection
  {
    op: 'd',
    ns: ' sample_mflix.sessions',
    ui: new UUID("99f8f10f-e144-4419-a543-da211dd1a2de"),
    o: { _id: ObjectId("65b1a0a4edf7e1f8d9ccc396") },
    ts: Timestamp({ t: 1710267182, i: 5 }),
    t: Long("38"),
    v: Long("2"),
    wall: ISODate("2024-03-12T18:13:02.838Z")
  },

Inspect a single oplog document to see an operation, namespace, timestamp, and wall-clock time stored in the oplog. section 9.1.3

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines configured versus actual capacity and demonstrates monitoring output, but does not detail all sizing defaults or resizing procedures.
Examples
Demonstrates a 4096 MB oplog, 4074.63 MB in use, a 176.43-hour window, and individual oplog operation documents.
What you can do after
Diagnose replication conditions with db.getReplicationInfo() and inspect oplog capacity, usage, and time coverage.
How it connects
Connects oplog size with replica sets, replication lag, storage engines, and replication-status commands.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.