对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

副本集成员状态

副本集的每个成员都有一个状态。

数值
名称
状态描述

0

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

处于主节点状态的成员是唯一可以接受写入操作的成员。有资格投票。

2

处于从节点状态的成员正在复制数据存储。有资格投票。

3

成员要么执行启动自检,要么完成回滚重新同步后进行转换。数据无法用于来自此成员的读取。有资格投票。

5

节点正在运行初始同步。有资格投票,但新添加到副本集时除外。

6

从集合中的另一个成员来看,该成员的状态尚不清楚。

7

仲裁节点不复制数据,其存在的唯一目的是参与选举。有资格投票。

8

从集合的另一个成员来看,该成员是无法访问的。

9

该成员正在主动执行回滚。有资格投票。数据无法用于来自此成员的读取。

Starting in version 4.2, MongoDB kills all in-progress user operations when a member enters the ROLLBACK state.

10

此成员曾经在副本集中,但随后被删除。

PRIMARY

Members in PRIMARY state accept write operations. A replica set has at most one primary at a time. [1] A SECONDARY member becomes primary after an election. Members in the PRIMARY state are eligible to vote.

SECONDARY

Members in SECONDARY state replicate the primary's data set and can be configured to accept read operations. Secondaries are eligible to vote in elections, and may be elected to the PRIMARY state if the primary becomes unavailable.

ARBITER

Members in ARBITER state do not replicate data or accept write operations. They are eligible to vote, and exist solely to break a tie during elections. Replica sets should only have a member in the ARBITER state if the set would otherwise have an even number of voting members, and could suffer from tied elections. There should only be at most one arbiter configured in any replica set. For considerations when using an arbiter, see Replica Set Arbiter.

有关核心状态的详细信息,请参阅副本集成员

STARTUP

Each member of a replica set starts up in STARTUP state. mongod then loads that member's replica set configuration, and transitions the member's state to STARTUP2 or ARBITER. Members in STARTUP are not eligible to vote, as they are not yet a recognized member of any replica set.

STARTUP2

在版本5.0中进行了更改。

Each data-bearing member of a replica set enters the STARTUP2 state as soon as mongod finishes loading that member's configuration.

The member then decides whether or not to undertake an initial sync. If a member begins an initial sync, the member remains in STARTUP2 until all data is copied and all indexes are built. Afterwards, the member transitions to RECOVERING.

Newly-added members in STARTUP2 are not eligible to vote and cannot be elected during the initial sync process. Prior to MongoDB 5.0, members in STARTUP2 were eligible to vote.

RECOVERING

A member of a replica set enters RECOVERING state when it is not ready to accept reads. The RECOVERING state can occur during normal operation, and doesn't necessarily reflect an error condition. Members in the RECOVERING state are eligible to vote in elections, but are not eligible to enter the PRIMARY state.

A member transitions from RECOVERING to SECONDARY after replicating enough data to guarantee a consistent view of the data for client reads. The only difference between RECOVERING and SECONDARY states is that RECOVERING prohibits client reads and SECONDARY permits them. SECONDARY state does not guarantee anything about the staleness of the data with respect to the primary.

Due to overload, a secondary may fall far enough behind the other members of the replica set such that it may need to resync with the rest of the set. When this happens, the member enters the RECOVERING state and requires manual intervention.

ROLLBACK

Whenever the replica set replaces a primary in an election, the old primary may contain documents that did not replicate to the secondary members. In this case, the old primary member reverts those writes. During rollback, the member will have ROLLBACK state. Members in the ROLLBACK state are eligible to vote in elections.

Starting in version 4.2, MongoDB kills all in-progress user operations when a member enters the ROLLBACK state.

处于任何错误状态的成员都不能投票。

UNKNOWN

Members that have never communicated status information to the replica set are in the UNKNOWN state.

DOWN

Members that lose their connection to the replica set are seen as DOWN by the remaining members of the set.

REMOVED

Members that are removed from the replica set enter the REMOVED state. When members enter the REMOVED state, the logs will mark this event with a replSet REMOVED message entry.

[1]

某些情况下,副本集中的两个节点可能会暂时认为它们是主节点,但最多只能有其中一个节点能够完成具有{ w: "majority" }写入关注的写入操作。可以完成{ w: "majority" }写入操作的节点是当前主节点,另一个节点是尚未识别其降级(通常是由于网络分区)的前主节点。发生这种情况时,尽管已请求读取偏好primary,但连接到前主节点的客户端可能会观察到过时数据,并且对前主节点的新写入操作最终将回滚。

给本页内容打分