On this page
isMaster
On this page
Definition
isMaster
-
isMaster
returns a document that describes the role of themongod
instance.If the instance is a member of a replica set, then
isMaster
returns 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
mongod
instance that is not a member of a replica set,isMaster
returns a subset of this information.MongoDB drivers and clients use
isMaster
to determine the state of the replica set members and to discover additional members of a replica set.The
db.isMaster()
method in themongo
shell provides a wrapper aroundisMaster
.The command takes the following form:
{ isMaster: 1 }
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 amongos
instance, or a standalonemongod
.This field will be
false
if 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
mongod
process. 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
48000000
bytes.
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
100,000
writes.Changed in version 3.6: The limit raises from
1,000
to100,000
writes. This limit also applies to legacyOP_INSERT
messages.
isMaster.
localTime
-
Returns the local server time in UTC. This value is an ISO date.
isMaster.
logicalSessionTimeoutMinutes
-
New in version 3.6.
The time in minutes that a session remains active after its most recent use. Sessions that have not received a new read/write operation from the client or been refreshed with
refreshSessions
within this threshold are cleared from the cache. State associated with an expired session may be cleaned up by the server at any time.Only available when
featureCompatibilityVersion
is"3.6"
. See Backwards Incompatible Features.
isMaster.
minWireVersion
-
New in version 2.6.
The earliest version of the wire protocol that this
mongod
ormongos
instance is capable of using to communicate with clients.Clients may use
minWireVersion
to help negotiate compatibility with MongoDB.
isMaster.
maxWireVersion
-
New in version 2.6.
The latest version of the wire protocol that this
mongod
ormongos
instance is capable of using to communicate with clients.Clients may use
maxWireVersion
to help negotiate compatibility with MongoDB.
isMaster.
readOnly
-
New in version 3.4.
A boolean value that, when
true
, indicates that themongod
ormongos
is running in read-only mode.
isMaster.
compression
-
New in version 3.4.
An array listing the compression algorithms used or available for use (i.e. common to both the client and the
mongod
ormongos
instance) to compress the communication between the client and themongod
ormongos
instance.The field is only available if compression is used. For example:
If the
mongod
is enabled to use both thesnappy,zlib
compressors and a client has specifiedzlib
, thecompression
field would contain:"compression": [ "zlib" ]
If the
mongod
is enabled to use both thesnappy,zlib
compressors and a client has specifiedzlib,snappy
, thecompression
field would contain:"compression": [ "zlib", "snappy" ]
If the
mongod
is enabled to use thesnappy
compressor and a client has specifiedzlib,snappy
, thecompression
field would contain :"compression": [ "snappy" ]
If the
mongod
is enabled to use thesnappy
compressor and a client has specifiedzlib
or the client has specified no compressor, the field is omitted.That is, if the client does not specify compression or if the client specifies a compressor not enabled for the connected
mongod
ormongos
instance, the field does not return.
Replica Sets
isMaster
contains these fields when returned by a member of a replica set:
isMaster.
secondary
-
A boolean value that, when
true
, indicates if themongod
is 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.passives
to 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].priority
of0
.This field only appears if there is at least one member with a
members[n].priority
of0
.Drivers use this array and the
isMaster.hosts
to 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. ThearbiterOnly
field is only present, if the instance is an arbiter.
isMaster.
passive
-
A boolean value that, when
true
, indicates that the current instance is passive. Thepassive
field is only present for members with amembers[n].priority
of0
.
-
A boolean value that, when
true
, indicates that the current instance is hidden. The