replSetGetConfig

On this page本页内容

Definition定义

replSetGetConfig

Returns a document that describes the current configuration of the replica set.返回描述副本集当前配置的文档。

Syntax语法

To run, replSetGetConfig must be issued against the admin database and has the following syntax:要运行,必须针对admin数据库发出replSetGetConfig,并具有以下语法:

db.adminCommand( {
   replSetGetConfig: 1,
   commitmentStatus: <boolean>,
   comment: <any>
} );
Field字段Type类型Description描述
replSetGetConfiganyAny value任何值
commitmentStatusboolean

Optional. 可选。Specify true to include a commitmentStatus field in the output. 指定true以在输出中包含commitmentStatus字段。The commitmentStatus output field indicates whether the replica set's previous reconfig has been committed, so that the replica set is ready to be reconfigured again. commitmentStatus输出字段指示副本集以前的重新配置是否已提交,以便副本集可以再次重新配置。For details, see commitmentStatus Output Field.有关详细信息,请参阅commitmentStatus输出字段

You can only specify commitmentStatus: true option when running the command on the primary. 在主服务器上运行命令时,只能指定commitmentStatus: true选项。The command errors if run with commitmentStatus: true on a secondary.如果在辅助服务器上以commitmentStatus: true运行,则命令将出错。

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

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中新增

mongosh provides the rs.conf() method that wraps the replSetGetConfig command:提供了包装replSetGetConfig命令的rs.conf()方法:

rs.conf();

Output Example输出示例

The following is an example output of the replSetGetConfig command run with commitmentStatus: true on the primary:以下是在primary上使用commitmentStatus: true运行的replSetGetConfig命令的示例输出:

{
   "config" : {
      "_id" : "myRepl",
      "version" : 180294,
      "term" : 1,
      "protocolVersion" : NumberLong(1),
      "writeConcernMajorityJournalDefault" : true,
      "members" : [
         {
            "_id" : 0,
            "host" : "m1.example.net:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {
            },
            "secondaryDelaySecs" : NumberLong(0),
            "votes" : 1
         },
         {
            "_id" : 1,
            "host" : "m2.example.net:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {
            },
            "secondaryDelaySecs" : NumberLong(0),
            "votes" : 1
         },
         {
            "_id" : 2,
            "host" : "m3.example.net:27017",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {
            },
            "secondaryDelaySecs" : NumberLong(0),
            "votes" : 1
         }
      ],
      "settings" : {
         "chainingAllowed" : true,
         "heartbeatIntervalMillis" : 2000,
         "heartbeatTimeoutSecs" : 10,
         "electionTimeoutMillis" : 10000,
         "catchUpTimeoutMillis" : -1,
         "catchUpTakeoverDelayMillis" : 30000,
         "getLastErrorModes" : {
         },
         "getLastErrorDefaults" : {
            "w" : 1,
            "wtimeout" : 0
         },
         "replicaSetId" : ObjectId("5eaa1e9ac4d650aa7817623d")
      }
   },
   "commitmentStatus" : true,  // Available in MongoDB 4.4
   "ok" : 1,
   "$clusterTime" : {
      "clusterTime" : Timestamp(1588212091, 1),
      "signature" : {
         "hash" : BinData(0,"veOHa2mOeRTzuR0LKqnzGxWV77k="),
         "keyId" : NumberLong("6821298283919441923")
      }
   },
   "operationTime" : Timestamp(1588212091, 1)
}
Field字段Description描述
configThe replica set configuration. 副本集配置。For description of each configuration settings, see Replica Set Configuration. 有关每个配置设置的说明,请参阅副本集配置
commitmentStatus

A boolean that indicates whether the most recent replica set configuration has been committed; i.e.一个布尔值,指示是否已提交最近的副本集配置;即。

  • The most recent replica set configuration for the primary has propagated to a majority of members, and主副本集的最新副本集配置已传播到大多数成员,并且
  • The last write operation to the replica set with the previous configuration has been majority-commited in the new configuration.对具有先前配置的副本集的最后一次写入操作已在新配置中majority-commited

If true, then the configuration has been committed, and the replica set can be reconfigured. 如果为true,则说明配置已提交,并且可以重新配置副本集。To reconfigure the replica set, see replSetReconfig command or the mongosh method rs.reconfig().要重新配置副本集,请参阅replSetReconfig命令或mongosh方法rs.reconfig()

If false, then the configuration has not been committed, and the replica set cannot be reconfigured.如果为false,则表示尚未提交配置,并且无法重新配置副本集。

okA number that indicates whether the command has succeeded (1) or failed (0). 指示命令是否成功(1)或失败(0)的数字。
operationTime
$clusterTime
Returned with every command for a replica set. 随副本集的每个命令返回。See db.adminCommand Response for details. 有关详细信息,请参阅db.adminCommand响应
Tip提示
See also: 参阅:
←  replSetFreezereplSetGetStatus →