A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/manual/reference/command/replSetResizeOplog/ below:

replSetResizeOplog (database command) - Database Manual

replSetResizeOplog

replSetResizeOplog also supports specifying the minimum number of hours to preserve an oplog entry.

Changed in version 5.0: To set the replSetOplog size in mongosh, use the Double() constructor.

replSetResizeOplog enables you to resize the oplog or its minimum retention period dynamically without restarting the mongod process.

You must run this command against the admin database.

This command is available in deployments hosted in the following environments:

Important

This command is not supported in MongoDB Atlas clusters. For information on Atlas support for all commands, see Unsupported Commands.

The command has the following form:

db.adminCommand(   {     replSetResizeOplog: <int>,     size: <double>,     minRetentionHours: <double>   } )

The command takes the following fields:

Field

Type

Description

replSetResizeOplog

int

Set to 1.

size

double

The maximum size of the oplog in megabytes.

minRetentionHours

double

Optional. The minimum number of hours to preserve an oplog entry, where decimal values represent the fractions of an hour. For example, a value of 1.5 represents one hour and thirty minutes.

The value must be greater than or equal to 0. A value of 0 indicates that the mongod should truncate the oplog starting with the oldest entries to maintain the configured maximum oplog size.

A mongod configured with minRetentionHours only removes an oplog entry if:

To check the currently configured minimum oplog retention period, see the oplogTruncation.oplogMinRetentionHours in the output of the serverStatus command.

You can use replSetResizeOplog on mongod instances running with the Wired Tiger storage engine or the in-memory storage engine.

See the Change the Oplog Size of Self-Managed Replica Set Members tutorial for a procedure on using replSetResizeOplog command to resize the oplog.

The oplog can grow past its configured size limit to avoid deleting the majority commit point.

You cannot drop the local.oplog.rs collection. For more information on this restriction, see Oplog Collection Behavior.

replSetResizeOplog overrides the maximum oplog size or minimum oplog retention period set at startup by:

The new oplog size persists after a server restart, unless you use:

Important

Reducing the maximum oplog size results in truncation of the oldest oplog entries until the oplog reaches the new configured size.

Similarly, reducing the minimum oplog retention period results in truncation of oplog entries older that the specified period if the oplog has exceeded the maximum configured size.

Oplog truncation due to reduced oplog size or retention period can result in unexpected behavior from clients still reading those oplog entries, including:

A mongod has the following behavior when configured with a minimum oplog retention period:

Changing the oplog size or minimum oplog retention period 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 or minimum retention period for all members.

Reducing the oplog size does not immediately reclaim that disk space. This includes oplog size reduction due to truncation of oplog events older than of the minimum oplog retention period.

To immediately free unused disk space after reducing the oplog size, run compact against the oplog.rs collection in the local database during a maintenance period. compact blocks all operations on the database it runs against. Running compact against oplog.rs therefore prevents oplog synchronization. For a procedure on resizing the oplog and compacting oplog.rs, see Change the Oplog Size of Self-Managed Replica Set Members.

replSetResizeOplog takes an exclusive (W) lock on the oplog and blocks other operations on the collection until it finishes.

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

Use the db.collection.stats() mongosh method to display the current maximum oplog size, maxSize, in megabytes. For example:

db.getSiblingDB("local").oplog.rs.stats(1024*1024).maxSize

The above command returns the oplog size of this member in megabytes:

The following command uses replSetResizeOplog to change the oplog size of this member to 16384 megabytes:

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

To verify the new oplog size, rerun the db.collection.stats() method:

db.getSiblingDB("local").oplog.rs.stats(1024*1024).maxSize

The above command returns:

  1. Connect mongosh to the mongod replica set member.

  2. Optional. Use the db.serverStatus() command to verify the current minimum oplog retention value as oplogTruncation.oplogMinRetentionHours:

    db.getSiblingDB("admin").serverStatus().oplogTruncation.oplogMinRetentionHours

    The command returns the currently configured minimum oplog retention period for the mongod. For example:

    If the mongod has no minimum oplog retention period, the operation returns an empty result.

  3. Use the replSetResizeOplog command to modify the configured minimum oplog retention period. For example, the following sets the minimum oplog retention period to 2 hours:

    db.adminCommand({  "replSetResizeOplog" : 1,  "minRetentionHours" : 2})

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4