MongoDB Cluster Parameters
On this page
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
andmongos
.mongod
和mongos
。This is an object containing change stream configuration options.这是一个包含更改流配置选项的对象。You can only set您只能在changeStreamOptions
on mongos or a replica set primary.mongos
或副本集primary上设置changeStreamOptions
。The 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
isoff
, MongoDB uses the default retention policy: pre- and post-images are retained until the corresponding change stream events are removed from the oplog.expireAfterSeconds
为off
时,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 } }
}
} )-