getDefaultRWConcern

On this page本页内容

Definition定义

New in version 4.4.在版本4.4中新增

getDefaultRWConcern

The getDefaultRWConcern administrative command retrieves the global default read or write concern settings.getDefaultRWConcern管理命令检索全局默认读取或写入问题设置。

getDefaultRWConcern must be run against the admin database. 必须针对admin数据库运行。getDefaultRWConcern has the following form:具有以下形式:

db.adminCommand( { getDefaultRWConcern : 1 , inMemory: <boolean>, comment: <any> } )

getDefaultRWConcern has the following fields:具有以下字段:

Field字段Type类型Description描述
getDefaultRWConcernint

Set to 1.设置为1

inMemoryboolean

Optional.可选。

Set to true to return the in-memory cached copy of the global default read or write concern settings. 设置为true可返回全局默认读写问题设置的内存缓存副本。The instance uses the in-memory copy when applying the global defaults to an operation.实例在将全局默认值应用于操作时使用内存中的副本。

Set to false to return the on-disk copy of the deployment's global default read or write concern. 设置为false将返回部署的全局默认读或写问题的磁盘副本。Defaults to false.默认为false

commentany

Optional. 可选。A user-provided comment to attach to this command. 用户提供了附加到此命令的注释。Once set, this comment appears alongside records of this command in the following locations:设置后,此注释将与此命令的记录一起显示在以下位置:

A comment can be any valid BSON type(string, integer, object, array, etc).注释可以是任何有效的BSON类型(字符串、整数、对象、数组等)。

New in version 4.4.在版本4.4中新增

getDefaultRWConcern output includes the following fields.输出包括以下字段。

Field字段Type类型Description描述
defaultWriteConcernobject

The global default write concern configuration. 全局默认写入关注配置。If this field is absent, the deployment has no global default write concern settings.如果不存在此字段,则部署没有全局默认写问题设置。

defaultReadConcernobject

The global default read concern configuration. 全局默认读取关注配置。If this field is absent, the deployment has no global default read concern settings.如果缺少此字段,则部署没有全局默认读取问题设置。

defaultWriteConcernSourceString

The source of the default write concern. 默认写入关注的来源。By default, the value is "implicit". 默认情况下,该值为"implicit"Once you set the default write concern with setDefaultRWConcern, the value becomes "global".使用setDefaultRWConcern设置默认写入关注点后,该值将变为"global"

defaultReadConcernSourceString

The source of the default read concern. 默认读取关注的来源。By default, the value is "implicit". 默认情况下,该值为"implicit"Once you set the default read concern with setDefaultRWConcern, the value becomes "global".使用setDefaultRWConcern设置默认读取关注点后,该值将变为“全局”。

updateOpTimeTimestamp

The operation timestamp of when any global default read or write concern setting was last modified. 上次修改任何全局默认读取或写入问题设置时的操作时间戳。Present if a default has ever been set for the cluster.如果为集群设置了默认值,则显示。

updateWallClockTimeDate

The wall clock date when an administrator last set the global default read or write concern. 管理员上次设置全局默认读写问题时的挂钟日期。This value is informational and should not be used for any recency comparisons.此值仅供参考,不应用于任何最近的比较。

localUpdateWallClockTimeDate

The wall clock date when the mongod or mongos last updated its local copy of the global default read and write concern settings. mongodmongos上次更新全局默认读写问题设置的本地副本时的挂钟日期。This value is informational and should not be used for any recency comparisons.此值仅供参考,不应用于任何最近的比较。

Tip提示
See also: 参阅:

Behavior行为

Note注意
Requires featureCompatibilityVersion 4.4+需要功能兼容性版本4.4+

Each mongod in the replica set or sharded cluster must have featureCompatibilityVersion set to at least 4.4 to use getDefaultRWConcern. 副本集或分片集群中的每个mongod必须将featureCompatibilityVersion设置为至少4.4才能使用getDefaultRWConcernIf you downgrade your deployment's featureCompatibilityVersion from 4.4 to 4.2, all cluster-wide read and write concern defaults are lost, but mongos instances may continue applying the defaults for up to 30 seconds.如果将部署的featureCompatibilityVersion4.4降级到4.2,则所有集群范围的读写问题默认值都将丢失,但mongos实例可能会继续应用默认值长达30秒。

Replica Sets复制集

You can issue getDefaultRWConcern against any data-bearing member of the replica set (i.e. not against an arbiter).您可以针对副本集的任何数据承载成员发出getDefaultRWConcern(即,不针对仲裁器)。

A secondary can return a 'stale' version of the global default settings if it has not yet replicated the latest changes from the primary.如果辅助服务器尚未从主服务器复制最新更改,则可以返回全局默认设置的“过时”版本。

Sharded Clusters分片状群集

Issue the setDefaultRWConcern against a mongos in the cluster.针对集群中的mongos发出setDefaultRWConcern

Each mongos periodically refreshes its local copy of the global default settings. 每个mongo都会定期刷新其全局默认设置的本地副本。A mongos can return a 'stale' version of the global default settings if it has not yet refreshed its local copy after a recent update to the global default settings or if it fetched its settings from a lagged config server secondary.如果mongos在最近更新全局默认设置后尚未刷新其本地副本,或者从滞后的配置服务器辅助服务器获取其设置,则mongos可以返回全局默认设置的“过时”版本。

The global default settings do not propagate to the individual shards. 全局默认设置不会传播到各个分片。You cannot run getDefaultRWConcern against a shard.不能对分片运行getDefaultRWConcern

Access Control访问控制

For replica sets or sharded clusters enforcing Authentication, getDefaultRWConcern requires that the authenticated user have the getDefaultRWConcern privilege action.对于实施身份验证的副本集或分片化集群,getDefaultRWConcern要求经过身份验证的用户具有getDefaultRWConcern权限操作。

The clusterManager or clusterMonitor built-in roles provides the required privileges to run getDefaultRWConcern.clusterManagerclusterMonitor内置角色提供运行getDefaultRWConcern所需的权限。

Example示例

The following operation retrieves the currently configured global default read and write concern for the mongod.以下操作检索mongod当前配置的全局默认读写关注点。

db.adminCommand({
  "getDefaultRWConcern": 1
})

The operation returns output similar to the following:该操作返回的输出类似于以下内容:

{
  "defaultWriteConcern" : {
    "w" : "majority"
  },
  "defaultReadConcern" : {
    "level" : "majority"
  },
  "defaultWriteConcernSource" : "global",
  "defaultReadConcernSource" : "global",
  "updateOpTime" : Timestamp(1586290895, 1),
  "updateWallClockTime" : ISODate("2020-04-07T20:21:41.849Z"),
  "localUpdateWallClockTime" : ISODate("2020-04-07T20:21:41.862Z"),
  "ok" : 1,
  "$clusterTime" : { ... }
  "operationTime" : Timestamp(1586290925, 1)
}
←  getAuditConfiggetParameter →