Navigation

replSetResizeOplog

On this page

Definition

replSetResizeOplog

New in version 3.6.

The replSetResizeOplog dynamically resizes a replica set member’s oplog to satisfy the operational needs in a replica set. It bypasses the need to perform a maintenance operation to resize the oplog. The command may only be run against the admin database.

This feature is only available for nodes running on the WiredTiger storage engine. If you are using the MMAPv1 storage engine, see Change the Size of the Oplog to follow the maintenance procedure.

The command has the following form:

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

Note

replSetResizeOplog takes the size parameter in megabytes, while the oplog size is stored in bytes. The size parameter must also be over 990 megabytes.

Example

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

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

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
db.oplog.rs.stats().maxSize

The above command returns:

"maxSize": NumberLong("17179869184")

Warning

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-replica-set-member.