Change the Size of the Oplog
On this page
New in version 3.6.
Connect to the replica set member using the
maxSize field displays the collection size in bytes.
To change the size, run the
replSetResizeOplog 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.
Reducing the size of the oplog does not automatically reclaim the disk space allocated to the original oplog size. You must run
compact against the
oplog.rs collection in the
local database to reclaim disk space. There are no benefits to running
compact on the
oplog.rs collection after increasing the oplog size.
The replica set member cannot replicate oplog entries while the
compact operation is ongoing. While
compact runs, the member may fall so far behind the primary that it cannot resume replication. The likelihood of a member becoming “stale” during the
compact procedure increases with cluster write throughput, and may be further exacerbated by the reduced oplog size.
Consider scheduling a maintenance window during which writes are throttled or stopped to mitigate the risk of the member becoming “stale” and requiring a full resync.
Do not run
compact against the primary replica set member. Connect a
mongo shell to the primary and run
rs.stepDown(). If successful, the primary steps down and closes all open connections. Reconnect the
mongo shell to the member and run the
compact command on the member.
The following operation runs the
compact command against the
For clusters enforcing authentication, authenticate as a user with the
compact privilege action on the
local database and the
oplog.rs collection. For complete documentation on
compact authentication requirements, see compact Required Privileges.