This version of the documentation is archived and no longer supported.


On this page



New in version 3.6.

Use the replSetResizeOplog administrative command to change the size of a replica set member’s oplog. [1] replSetResizeOplog enables you to resize the oplog dynamically without restarting the mongod process.

You must run this command against the admin database.

The command has the following form:

{ replSetResizeOplog: <boolean>, size: <num MB> }


replSetResizeOplog takes the size parameter in megabytes while the oplog size is stored in bytes:

  • The minimum size you can specify is 990 megabytes.
  • The maximum size you can specify is 1 petabytes.


You can only use replSetResizeOplog on mongod instances running with the Wired Tiger storage engine.

In MongoDB versions 3.4 and earlier, the oplog was resized by dropping and recreating the collection. In MongoDB versions 3.6 and later, use the replSetResizeOplog command to resize the oplog as shown in the Change the Size of the Oplog tutorial. Starting in MongoDB 4.0, MongoDB forbids dropping the collection. For more information on this restriction, see Oplog Collection Behavior.

Changing the oplog size of a given replica set member with replSetResizeOplog does not change the oplog size of any other member in the replica set. You must run replSetResizeOplog on each replica set member in your cluster to change the oplog size for all members.

Reducing the oplog size does not reclaim that disk space automatically. You must run compact against the collection in the local database. compact blocks all operations on the database it runs against. Running compact against therefore prevents oplog synchronization. For a procedure on resizing the oplog and compacting, see Change the Size of the Oplog.

Resource Locking

replSetResizeOplog takes a global exclusive (W) lock and blocks all other operations until it finishes.

For more information on locking in MongoDB, see FAQ: Concurrency.


Use the stats command to display the current oplog size, maxSize. For example:

use local

The above command will return the oplog size of this member:

"maxSize": NumberLong("9790804377")

maxSize is currently 9790804377 bytes, or 9337 megabytes.

The following command changes the oplog size of this member to 17179869184 bytes, or 16384 megabytes.

To change the size, run the replSetResizeOplog, passing the desired size in megabytes as a parameter.

db.adminCommand({replSetResizeOplog:1, size: 16384})

To verify the new oplog size, rerun the stats command:

use local

The above command returns:

"maxSize": NumberLong("17179869184")


Reducing the size of the oplog in a node removes data from it. This may cause replica members syncing with that node to become stale. To resync those members, see Resync a Member of a Replica Set.

[1]Starting in MongoDB 4.0, the oplog can grow past its configured size limit to avoid deleting the majority commit point.