- Reference >
- Database Commands >
- Replication Commands >
- isMaster
isMaster¶
On this page
Definition¶
-
isMaster¶ isMasterreturns a document that describes the role of themongodinstance.If the instance is a member of a replica set, then
isMasterreturns a subset of the replica set configuration and status including whether or not the instance is the primary of the replica set.When sent to a
mongodinstance that is not a member of a replica set,isMasterreturns a subset of this information.MongoDB drivers and clients use
isMasterto determine the state of the replica set members and to discover additional members of a replica set.The
db.isMaster()method in themongoshell provides a wrapper aroundisMaster.The command takes the following form:
Output¶
All Instances¶
The following isMaster fields are common across all
roles:
-
isMaster.ismaster¶ A boolean value that reports when this node is writable. If
true, then this instance is a primary in a replica set, or a master in a master-slave configuration, or amongosinstance, or a standalonemongod.This field will be
falseif the instance is a secondary member of a replica set or if the member is an arbiter of a replica set.
-
isMaster.maxBsonObjectSize¶ The maximum permitted size of a BSON object in bytes for this
mongodprocess. If not provided, clients should assume a max size of “16 * 1024 * 1024”.
-
isMaster.maxMessageSizeBytes¶ The maximum permitted size of a BSON wire protocol message. The default value is
48000000bytes.
-
isMaster.maxWriteBatchSize¶ The maximum number of write operations permitted in a write batch. If a batch exceeds this
limit, the client driver divides the batch into smaller groups each with counts less than or equal to the value of this field.The value of this limit is
1,000writes.
-
isMaster.minWireVersion¶ New in version 2.6.
The earliest version of the wire protocol that this
mongodormongosinstance is capable of using to communicate with clients.Clients may use
minWireVersionto help negotiate compatibility with MongoDB.
-
isMaster.maxWireVersion¶ New in version 2.6.
The latest version of the wire protocol that this
mongodormongosinstance is capable of using to communicate with clients.Clients may use
maxWireVersionto help negotiate compatibility with MongoDB.
-
isMaster.readOnly¶ New in version 3.4.
A boolean value that, when
true, indicates that themongodormongosis running in read-only mode.
-
isMaster.compression¶ New in version 3.4.
An array listing the compression algorithms used to compress the current connection’s network communication between the
mongodormongosand other members of the deployment or themongoshell.For a
mongodormongosusing thesnappycompressor , thecompressionfield would resemble the following:
Replica Sets¶
isMaster contains these fields when returned by a member
of a replica set:
-
isMaster.setName¶ The name of the current :replica set.
-
isMaster.setVersion¶ New in version 2.6.
The current replica set config version.
-
isMaster.secondary¶ A boolean value that, when
true, indicates if themongodis a secondary member of a replica set.
-
isMaster.hosts¶ An array of strings in the format of
"[hostname]:[port]"that lists all members of the replica set that are neither hidden, passive, nor arbiters.Drivers use this array and the
isMaster.passivesto determine which members to read from.
-
isMaster.passives¶ An array of strings in the format of
"[hostname]:[port]"listing all members of the replica set which have amembers[n].priorityof0.This field only appears if there is at least one member with a
members[n].priorityof0.Drivers use this array and the
isMaster.hoststo determine which members to read from.
-
isMaster.arbiters¶ An array of strings in the format of
"[hostname]:[port]"listing all members of the replica set that are arbiters.This field only appears if there is at least one arbiter in the replica set.
-
isMaster.primary¶ A string in the format of
"[hostname]:[port]"listing the current primary member of the replica set.
-
isMaster.arbiterOnly¶ A boolean value that , when
true, indicates that the current instance is an arbiter. ThearbiterOnlyfield is only present, if the instance is an arbiter.
-
isMaster.passive¶ A boolean value that, when
true, indicates that the current instance is passive. Thepassivefield is only present for members with amembers[n].priorityof0.
A boolean value that, when
true, indicates that the current instance is hidden. Thehiddenfield is only present for hidden members.
A tag set document containing mappings of arbitrary keys and values. These documents describe replica set members in order to customize write concern and read preference and thereby allow configurable data center awareness.
This field is only present if there are tags assigned to the member. See Configure Replica Set Tag Sets for more information.
-
isMaster.electionId¶ New in version 3.0.
A unique identifier for each election. Included only in the output of
isMasterfor the primary. Used by clients to determine when elections occur.
-
isMaster.lastWrite¶ New in version 3.4.
A document containing optime and date information for the database’s most recent write operation.
-
isMaster.lastWrite.majorityOpTime¶ An object giving the optime of the last write operation readable by
majorityreads.This field only appears on
mongodinstances started with the--enableMajorityReadConcernoption.
-
isMaster.lastWrite.majorityWriteDate¶ A
dateobject containing the time of the last write operation readable bymajorityreads.This field only appears on
mongodinstances started with the--enableMajorityReadConcernoption.
-