replSetGetConfig
Returns a document that describes the current configuration of the replica set.
TipIn mongosh
, this command can also be run through the rs.conf()
helper method.
Helper methods are convenient for mongosh
users, but they may not return the same level of information as database commands. In cases where the convenience is not needed or the additional return fields are required, use the database command.
This command is available in deployments hosted in the following environments:
MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud
This command is not supported in M0 and Flex clusters. For more information, see Unsupported Commands.
MongoDB Enterprise: The subscription-based, self-managed version of MongoDB
MongoDB Community: The source-available, free-to-use, and self-managed version of MongoDB
To run, replSetGetConfig
must be issued against the admin
database. The command has the following syntax:
db.adminCommand( { replSetGetConfig: 1, commitmentStatus: <boolean>, comment: <any> })
Field
Type
Description
replSetGetConfig
any
Any value
boolean
Optional. Specify true
to include a commitmentStatus field in the output. 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. For details, see commitmentStatus Output Field.
You can only specify commitmentStatus: true
option when running the command on the primary. The command errors if run with commitmentStatus: true
on a secondary.
comment
any
Optional. A user-provided comment to attach to this command. Once set, this comment appears alongside records of this command in the following locations:
mongod log messages, in the attr.command.cursor.comment
field.
Database profiler output, in the command.comment
field.
currentOp
output, in the command.comment
field.
A comment can be any valid BSON type (string, integer, object, array, etc).
mongosh
provides the rs.conf()
method that wraps the replSetGetConfig
command:
The following is an example output of the replSetGetConfig
command run with commitmentStatus: true on the primary:
{ "config" : { "_id" : "myRepl", "version" : 180294, "term" : 1, "protocolVersion" : Long(1), "writeConcernMajorityJournalDefault" : true, "members" : [ { "_id" : 0, "host" : "m1.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : { }, "secondaryDelaySecs" : Long(0), "votes" : 1 }, { "_id" : 1, "host" : "m2.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : { }, "secondaryDelaySecs" : Long(0), "votes" : 1 }, { "_id" : 2, "host" : "m3.example.net:27017", "arbiterOnly" : false, "buildIndexes" : true, "hidden" : false, "priority" : 1, "tags" : { }, "secondaryDelaySecs" : Long(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, "ok" : 1, "$clusterTime" : { "clusterTime" : Timestamp(1588212091, 1), "signature" : { "hash" : BinData(0,"veOHa2mOeRTzuR0LKqnzGxWV77k="), "keyId" : Long("6821298283919441923") } }, "operationTime" : Timestamp(1588212091, 1)}
Field
Description
config
The replica set configuration. For description of each configuration settings, see Self-Managed Replica Set Configuration.
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.
If true
, then the configuration has been committed, and the replica set can be reconfigured. To reconfigure the replica set, see replSetReconfig
command or the mongosh
method rs.reconfig()
.
If false
, then the configuration has not been committed, and the replica set cannot be reconfigured.
ok
A number that indicates whether the command has succeeded (1
) or failed (0
).
operationTime
$clusterTime
Returned with every command for a replica set. See db.adminCommand Response for details.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4