Docs Menu

Replica Set Primary

The primary is the only member in the replica set that receives write operations. MongoDB applies write operations on the primary and then records the operations on the primary's oplog. 보조 members replicate this log and apply the operations to their data sets.

멤버 셋으로 구성된 다음의 복제본 세트에서 주 노드는 모든 쓰기 연산을 허용합니다. 그런 다음 보조 멤버들이 oplog를 복제하여 데이터 세트에 적용합니다.

Diagram of default routing of reads and writes to the primary.
클릭하여 확대

복제본 세트의 모든 멤버는 읽기 연산을 허용할 수 있습니다. 그러나 기본적으로 애플리케이션은 주 멤버에게 읽기 연산을 지시합니다. 기본 읽기 동작 변경에 대한 자세한 내용은 읽기 기본 설정을 참조하세요.

The replica set can have at most one primary. [1] If the current primary becomes unavailable, an election determines the new primary. See 복제본 세트 선거 for more details.

In the following 3-member replica set, the primary becomes unavailable. This triggers an election which selects one of the remaining secondaries as the new primary.

Diagram of an election of a new primary. In a three member replica set with two secondaries, the primary becomes unreachable. The loss of a primary triggers an election where one of the secondaries becomes the new primary
클릭하여 확대
[1] 일부 상황에서는 복제본 세트의 두 노드가 일시적으로 자신이 주 노드라고 생각할 수 있지만, { w: "majority" }의 쓰기 우려로 쓰기를 완료할 수 있는 노드는 최대 한 개뿐입니다. { w: "majority" }개의 쓰기를 완료할 수 있는 노드가 현재의 주 노드이고, 다른 노드는 보통 네트워크 파티션으로 인해 강등된 것을 아직 인식하지 못한 이전의 주 노드입니다. 이 경우 이전 주 노드에 연결한 클라이언트는 읽기 기본 설정 primary를 요청했음에도 불구하고 오래된 데이터를 보게 되며, 이전의 주 노드에 대한 새로운 쓰기는 결국 롤백됩니다.