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. MongoDB在primary上应用写操作,然后将操作记录在primary的oplog上。Secondary members replicate this log and apply the operations to their data sets.成员复制此日志并将操作应用于其数据集。
In the following three-member replica set, the primary accepts all write operations. Then the secondaries replicate the oplog to apply to their data sets.在以下三个成员的复制副本集中,主复制副本接受所有写操作。然后,辅助设备复制oplog以应用于它们的数据集。
All members of the replica set can accept read operations. 复制副本集的所有成员都可以接受读取操作。However, by default, an application directs its read operations to the primary member. 但是,默认情况下,应用程序将其读取操作定向到主成员。See Read Preference for details on changing the default read behavior.有关更改默认读取行为的详细信息,请参阅读取首选项。
The replica set can have at most one primary. 复制副本集最多可以有一个主副本。[1] If the current primary becomes unavailable, an election determines the new primary. See Replica Set Elections for more details.如果当前初选不可用,则选举将确定新的初选。有关详细信息,请参阅副本集选举。
In the following 3-member replica set, the primary becomes unavailable. 在以下3个成员的复制集中,主复制副本将不可用。This triggers an election which selects one of the remaining secondaries as the new primary.这会触发一次选举,从剩下的中学中选择一所作为新的小学。
[1] | { w: "majority" } write concern. { w: "majority" } 写入关注的写入。{ w: "majority" } writes is the current primary, and the other node is a former primary that has not yet recognized its demotion, typically due to a network partition. { w: "majority" } 写入的节点是当前主节点,而另一个节点是尚未识别其降级的前主节点,通常是由于网络分区。primary , and new writes to the former primary will eventually roll back.primary ,并且对前一个主要服务器的新写入最终会回滚。 |