发布于 2015-09-14 14:54:30 | 236 次阅读 | 评论: 0 | 来源: 网络整理
The replSetGetStatus provides an overview of the current status of a replica set. Issue the following command against the admin database, in the mongo shell:
db.runCommand( { replSetGetStatus: 1 } )
You can also use the following helper in the mongo shell to access this functionality
rs.status()
The value specified (e.g 1 above,) does not impact the output of the command. Data provided by this command derives from data included in heartbeats sent to the current instance by other members of the replica set: because of the frequency of heartbeats, these data can be several seconds out of date.
注解
The mongod must have replication enabled and be a member of a replica set for the for replSetGetStatus to return successfully.
也可以参考
“rs.status()” shell helper function, “副本集”.
The set value is the name of the replica set, configured in the replSet setting. This is the same value as _id in rs.conf().
The value of the date field is an ISODate of the current time, according to the current server. Compare this to the value of the lastHeartbeat to find the operational lag between the current host and the other hosts in the set.
The value of myState reflects state of the current replica set member. An integer between 0 and 10 represents the state of the member. These integers map to states, as described in the following table:
Number | State |
0 | Starting up, phase 1 (parsing configuration) |
1 | Primary |
2 | Secondary |
3 | Recovering (initial syncing, post-rollback, stale members) |
4 | Fatal error |
5 | Starting up, phase 2 (forking threads) |
6 | Unknown state (the set has never connected to the member) |
7 | Arbiter |
8 | Down |
9 | Rollback |
10 | Removed |
The members field holds an array that contains a document for every member in the replica set. See the “Member Statuses” for an overview of the values included in these documents.
The syncingTo field is only present on the output of rs.status() on secondary and recovering members, and holds the hostname of the member from which this instance is syncing.
The name field holds the name of the server.
The self field is only included in the document for the current mongod instance in the members array. It’s value is true.
This field contains the most recent error or status message received from the member. This field may be empty (e.g. "") in some cases.
The health value is only present for the other members of the replica set (i.e. not the member that returns rs.status.) This field conveys if the member is up (i.e. 1) or down (i.e. 0.)
The value of the state reflects state of this replica set member. An integer between 0 and 10 represents the state of the member. These integers map to states, as described in the following table:
Number | State |
0 | Starting up, phase 1 (parsing configuration) |
1 | Primary |
2 | Secondary |
3 | Recovering (initial syncing, post-rollback, stale members) |
4 | Fatal error |
5 | Starting up, phase 2 (forking threads) |
6 | Unknown state (the set has never connected to the member) |
7 | Arbiter |
8 | Down |
9 | Rollback |
10 | Removed |
The uptime field holds a value that reflects the number of seconds that this member has been online.
This value does not appear for the member that returns the rs.status() data.
A document that contains information regarding the last operation from the operation log that this member has applied.
A 32-bit timestamp of the last operation applied to this member of the replica set from the oplog.
An incremented field, which reflects the number of operations in since the last time stamp. This value only increases if there is more than one operation per second.
An ISODate formatted date string that reflects the last entry from the oplog that this member applied. If this differs significantly from lastHeartbeat this member is either experiencing “replication lag” or there have not been any new operations since the last update. Compare members.optimeDate between all of the members of the set.
The lastHeartbeat value provides an ISODate formatted date of the last heartbeat received from this member. Compare this value to the value of the date field to track latency between these members.
This value does not appear for the member that returns the rs.status() data.
The pingMS represents the number of milliseconds (ms) that a round-trip packet takes to travel between the remote member and the local instance.
This value does not appear for the member that returns the rs.status() data.