MongoDB Cluster ParametersMongoDB集群参数
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. The setClusterParameter command is not available in MongoDB Atlas.setClusterParameter命令仅在自管理安装中可用。setClusterParameter命令在MongoDB Atlas中不可用。
Parameters参数
changeStreamOptionsNew in version 6.0.6.0版新增。Available for both可用于mongodandmongos.mongod和mongos。This is an object containing change stream configuration options.这是一个包含更改流配置选项的对象。You can only set您只能在changeStreamOptionson mongos or a replica set primary.mongos或副本集primary上设置changeStreamOptions。The value is set cluster-wide.该值是在集群范围内设置的。
changeStreamOptions.preAndPostImages.expireAfterSecondsNew 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.前映像和后映像分别是文档修改前后的版本。expireAfterSecondscontrols how long pre- and post-images are retained.控制保留前映像和后映像的时间。When当expireAfterSecondsisoff, 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使用默认的保留策略:保留前映像和后映像,直到从oplog中删除相应的更改流事件。To specify the minimum pre- and post-image retention time:要指定图像前和图像后的最小保留时间,请执行以下操作:Set使用整数设置expireAfterSecondsusing 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如果更改流事件从操作日志中删除,则相应的前映像和后映像也将被删除,而不管映像前和后映像的保留时间是expireAfterSecondspre- 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 } }
}
} )