On this page本页内容
New in version 4.4.在版本4.4中新增。
getDefaultRWConcern
The getDefaultRWConcern
administrative command retrieves the global default read or write concern settings.getDefaultRWConcern
管理命令检索全局默认读取或写入问题设置。
getDefaultRWConcern
on a mongos
.mongos
上发出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:具有以下字段:
getDefaultRWConcern | int |
|
inMemory | boolean |
|
comment | any |
|
getDefaultRWConcern
output includes the following fields.输出包括以下字段。
defaultWriteConcern | object |
|
defaultReadConcern | object |
|
defaultWriteConcernSource | String |
|
defaultReadConcernSource | String |
|
updateOpTime | Timestamp |
|
updateWallClockTime | Date |
|
localUpdateWallClockTime | Date |
|
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
才能使用getDefaultRWConcern
。If you downgrade your deployment's featureCompatibilityVersion from 如果将部署的featureCompatibilityVersion从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.4.4
降级到4.2
,则所有集群范围的读写问题默认值都将丢失,但mongos
实例可能会继续应用默认值长达30秒。
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.如果辅助服务器尚未从主服务器复制最新更改,则可以返回全局默认设置的“过时”版本。
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
。
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
.clusterManager
或clusterMonitor
内置角色提供运行getDefaultRWConcern
所需的权限。
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) }