Docs HomeMongoDB Manual

MongoDB Cluster Parameters

Synopsis提要

You can specify configuration options which affect all nodes in a replica set or sharded cluster. 您可以指定影响副本集中或分片集群中所有节点的配置选项。To set these options, use the setClusterParameter command:要设置这些选项,请使用setClusterParameter命令:

db.adminCommand( { setClusterParameter:{ <parameter>: <value> } } )

To view the current values of cluster parameters, use the getClusterParameter command:要查看集群参数的当前值,请使用getClusterParameter命令:

db.adminCommand( { getClusterParameter: <parameter> } )

The setClusterParameter command is only available in self-managed installations. setClusterParameter命令仅在自管理安装中可用。The setClusterParameter command is not available in MongoDB Atlas.setClusterParameter命令在MongoDB Atlas中不可用。

Parameters参数

changeStreamOptions

New in version 6.0.6.0版新增。

Available for both mongod and mongos.可用于mongodmongos

This is an object containing change stream configuration options.这是一个包含更改流配置选项的对象。

You can only set changeStreamOptions on mongos or a replica set primary. 您只能在mongos或副本集primary上设置changeStreamOptionsThe value is set cluster-wide.该值是在集群范围内设置的。

changeStreamOptions.preAndPostImages.expireAfterSeconds

New in version 6.0.6.0版新增。

Default: off

Controls the retention policy of change stream pre- and post-images. 控制更改流前映像和后映像的保留策略。Pre- and post-images are the versions of a document before and after document modification respectively. 前图像和后图像分别是文档修改前后的版本。expireAfterSeconds controls how long pre- and post-images are retained.expireAfterSeconds控制保留前图像和后图像的时间。

When expireAfterSeconds is off, MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog.expireAfterSecondsoff时,MongoDB使用默认的保留策略:保留前映像和后映像,直到从操作日志中删除相应的更改流事件。

To specify the minimum pre- and post-image retention time:要指定图像前和图像后的最小保留时间,请执行以下操作:

  • Set expireAfterSeconds using an integer.使用整数设置expireAfterSeconds

  • If a change stream event is removed from the oplog, then the corresponding pre- and post-images are also deleted regardless of the expireAfterSeconds pre- and post-image retention time.如果更改流事件从操作日志中删除,则相应的前映像和后映像也将被删除,而不管映像前和后映像的保留时间是expireAfterSeconds

The following example sets the retention time for pre- and post-images in change streams to 100 seconds:以下示例将更改流中前置和后置图像的保留时间设置为100秒:

db.runCommand( {
setClusterParameter: {
changeStreamOptions: { preAndPostImages: { expireAfterSeconds: 100 } }
}
} )