Navigation
This version of the documentation is archived and no longer supported.

isMaster

isMaster

The isMaster command provides a basic overview of the current replication configuration. MongoDB drivers and clients use this command to determine what kind of member they’re connected to and to discover additional members of a replica set. The db.isMaster() method provides a wrapper around this database command.

The command takes the following form:

{ isMaster: 1 }

This command returns a document containing the following fields:

isMaster.setname

The name of the current replica set, if applicable.

isMaster.ismaster

A boolean value that reports when this node is writable. If true, then the current node is either a primary in a replica set, a master in a master-slave configuration, or a standalone mongod.

isMaster.secondary

A boolean value that, when true, indicates that the current member is a secondary member of a replica set.

isMaster.hosts

An array of strings in the format of “[hostname]:[port]” listing all members of the replica set that are not “hidden”.

isMaster.arbiter

An array of strings in the format of “[hostname]:[port]” listing all members of the replica set that are arbiters

Only appears in the isMaster response for replica sets that have arbiter members.

isMaster.arbiterOnly

A boolean value that, when true indicates that the current instance is an arbiter.

arbiterOnly only appears in the isMaster response from arbiters.

isMaster.primary

The [hostname]:[port] for the current replica set primary, if applicable.

isMaster.me

The [hostname]:[port] of the node responding to this command.

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 “4 * 1024 * 1024”.

isMaster.localTime

New in version 2.1.1.

Returns the local server time in UTC. This value is a ISOdate. You can use the toString() JavaScript method to convert this value to a local date string, as in the following example:

db.isMaster().localTime.toString();
←   group isSelf (internal)  →