发布于 2015-09-14 15:05:37 | 251 次阅读 | 评论: 0 | 来源: 网络整理
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:
The name of the current replica set, if applicable.
A boolean value that reports when this node is writable. If true, then the current node is either a primary node in a replica set, a master node in a master-slave configuration, of a standalone mongod.
A boolean value that, when true, indicates that the current node is a secondary member of a replica set.
An array of strings in the format of “[hostname]:[port]” listing all nodes in the replica set that are not “hidden”.
The [hostname]:[port] for the current replica set primary, if applicable.
The [hostname]:[port] of the node responding to this command.