Navigation

replSetResizeOplog

On this page

Definition

replSetResizeOplog

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> }

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.

Behavior

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

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.

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 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.