Replica Set Secondary Members副本集辅助成员

A secondary maintains a copy of the primary's data set. 辅助服务器维护primary服务器数据集的副本。To replicate data, a secondary applies operations from the primary's oplog to its own data set in an asynchronous process. 为了复制数据,辅助服务器在异步进程中将主服务器oplog中的操作应用于其自己的数据集。[1] A replica set can have one or more secondaries.副本集可以有一个或多个辅助副本。

The following three-member replica set has two secondary members. 以下三成员副本集有两个辅助成员。The secondaries replicate the primary's oplog and apply the operations to their data sets.辅助服务器复制主服务器的oplog,并将操作应用于其数据集。

Diagram of a 3 member replica set that consists of a primary and two secondaries.

Although clients cannot write data to secondaries, clients can read data from secondary members. 尽管客户端无法将数据写入辅助成员,但客户端可以从辅助成员读取数据。See Read Preference for more information on how clients direct read operations to replica sets.有关客户端如何将读取操作定向到副本集的更多信息,请参阅读取首选项

A secondary can become a primary. 次级可以成为初级。If the current primary becomes unavailable, the replica set holds an election to choose which of the secondaries becomes the new primary.如果当前主副本不可用,则复制集将进行选举,以选择哪个辅助副本成为新的主副本。

In the following three-member replica set, the primary becomes unavailable. 在以下三个成员副本集中,主副本不可用。This triggers an election where one of the remaining secondaries becomes 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

See Replica Set Elections for more details.有关详细信息,请参阅复制集选举

You can configure a secondary member for a specific purpose. 您可以为特定目的配置辅助成员。You can configure a secondary to:您可以将辅助配置为:

[1] Starting in version 4.2 (also available starting in 4.0.6), secondary members of a replica set now log oplog entries that take longer than the slow operation threshold to apply. 从4.2版开始(从4.0.6版开始也可用),副本集的辅助成员现在记录的oplog条目比应用慢操作阈值所需的时间更长。These slow oplog messages:这些慢oplog消息:
  • Are logged for the secondaries in the diagnostic log.诊断日志中记录辅助设备。
  • Are logged under the REPL component with the text applied op: <oplog entry> took <num>ms.REPL组件下记录并应用文本操作:applied op: <oplog entry> took <num>ms
  • Do not depend on the log levels (either at the system or component level)不依赖于日志级别(在系统或组件级别)
  • Do not depend on the profiling level.不依赖于分析级别。
  • May be affected by slowOpSampleRate, depending on your MongoDB version:可能会受到slowOpSampleRate的影响,具体取决于您的MongoDB版本:
    • In MongoDB 4.2 and earlier, these slow oplog entries are not affected by the slowOpSampleRate. 在MongoDB 4.2及更早版本中,这些慢oplog条目不受slowOpSampleRate的影响。MongoDB logs all slow oplog entries regardless of the sample rate.无论采样率如何,MongoDB都会记录所有慢操作日志条目。
    • In MongoDB 4.4 and later, these slow oplog entries are affected by the slowOpSampleRate.在MongoDB 4.4及更高版本中,这些慢oplog条目受slowOpSampleRate的影响。
The profiler does not capture slow oplog entries.探查器不捕获慢oplog条目。
←  Replica Set PrimaryPriority 0 Replica Set Members →