replSetResizeOplog
Definition
New in version 3.6.
Use the replSetResizeOplog
administrative command tochange the size of a replica set member’s oplog. [1]replSetResizeOplog
enables you to resize the oplogdynamically 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 inmegabytes 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.
Behavior
You can only use replSetResizeOplog
onmongod
instances running with theWired Tiger storage engine.
Changing the oplog size of a given replica set member withreplSetResizeOplog
does not change the oplog size of anyother member in the replica set. You must runreplSetResizeOplog
on each replica set member in yourcluster to change the oplog size for all members.
Reducing the oplog size does not reclaim that disk spaceautomatically. You must run compact
against theoplog.rs
collection in the local
database. compact
blocks all operations on the database it runs against.Running compact
against oplog.rs
therefore prevents oplogsynchronization. For a procedure on resizing the oplog and compactingoplog.rs
, see Change the Size of the Oplog.
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 to17179869184 bytes, or 16384 megabytes.
To change the size, run the replSetResizeOplog
, passingthe 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. Thismay 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 sizelimit to avoid deleting the majority commit point . |