Navigation

Change the Size of the Oplog

New in version 3.6.

This procedure changes the size of the oplog [1] on each member of a replica set using the replSetResizeOplog command, starting with the secondary members before proceeding to the primary.

Important

You can only run replSetResizeOplog on replica set members running with the WiredTiger storage engine.

Perform these steps on each secondary replica set member first. Once you have changed the oplog size for all secondary members, perform these steps on the primary.

A. Connect to the replica set member

Connect to the replica set member using the mongo shell:

mongo --host <hostname>:<port>

Note

If the replica set enforces authentication, you must authenticate as a user with privileges to modify the local database, such as the clusterManager or clusterAdmin role.

B. (Optional) Verify the current size of the oplog

To view the current size of the oplog, switch to the local database and run db.collection.stats() against the oplog.rs collection. stats() displays the oplog size as maxSize.

use local
db.oplog.rs.stats().maxSize

The maxSize field displays the collection size in bytes.

C. Change the oplog size of the replica set member

To resize the oplog, run the replSetResizeOplog command, passing the desired size in megabytes as the size parameter. The specified size must be greater than 990, or 990 megabytes.

The following operation changes the oplog size of the replica set member to 16 gigabytes, or 16000 megabytes.

db.adminCommand({replSetResizeOplog: 1, size: 16000})
[1]Starting in MongoDB 4.0, the oplog can grow past its configured size limit to avoid deleting the majority commit point.