Replica Set Member States
最近写MongoDB监控脚本,要判断节点状态,这里整理了所有的节点状态值,对应 命令 rs.status().members 中的 state 和 stateStr 字段,如:
“state” : 3,
“stateStr” : “RECOVERING”
| 0 | STARTUP
| Not yet an active member of any set. All members start up in this state. The mongod
parses the replica set configuration document while in STARTUP
. |
| 1 | PRIMARY
| The member in state primary is the only member that can accept write operations. Eligible to vote. |
| 2 | SECONDARY
| A member in state secondary is replicating the data store. Eligible to vote. |
| 3 | RECOVERING
| Members either perform startup self-checks, or transition from completing a rollback or resync. Eligible to vote. |
| 5 | STARTUP2
| The member has joined the set and is running an initial sync. Eligible to vote. |
| 6 | UNKNOWN
| The member’s state, as seen from another member of the set, is not yet known. |
| 7 | ARBITER
| Arbiters do not replicate data and exist solely to participate in elections. Eligible to vote. |
| 8 | DOWN
| The member, as seen from another member of the set, is unreachable. |
| 9 | ROLLBACK
| This member is actively performing a rollback. Eligible to vote. Data is not available for reads from this member. |
| 10 | REMOVED
| This member was once in a replica set but was subsequently removed. |