发布于 2015-09-14 15:05:37 | 238 次阅读 | 评论: 0 | 来源: 网络整理

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 node in a replica set, a master node in a master-slave configuration, of a standalone mongod.

isMaster.secondary

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

isMaster.hosts

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

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

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();
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务