On this page本页内容
While replica sets provide basic protection against single-instance failure, replica sets whose members are all located in a single data center are susceptible to data center failures. 虽然副本集提供了针对单实例故障的基本保护,但其成员都位于单个数据中心的副本集容易受到数据中心故障的影响。Power outages, network interruptions, and natural disasters are all issues that can affect replica sets whose members are located in a single facility.停电、网络中断和自然灾害都可能影响其成员位于单个设施中的副本集。
Distributing replica set members across geographically distinct data centers adds redundancy and provides fault tolerance if one of the data centers is unavailable.跨地理位置不同的数据中心分布副本集成员会增加冗余,并在其中一个数据中心不可用时提供容错能力。
To protect your data in case of a data center failure, keep at least one member in an alternate data center. 为了在数据中心发生故障时保护数据,请在备用数据中心中至少保留一个成员。If possible, use an odd number of data centers, and choose a distribution of members that maximizes the likelihood that even with a loss of a data center, the remaining replica set members can form a majority or at minimum, provide a copy of your data.如果可能,请使用奇数个数据中心,并选择一种成员分布,以最大限度地提高即使丢失数据中心,其余副本集成员也可以构成大多数或至少提供数据副本的可能性。
For example, for a three-member replica set, some possible distributions of members include:例如,对于三成员副本集,一些可能的成员分布包括:
Two data centers: two members to Data Center 1 and one member to Data Center 2. 两个数据中心:数据中心1的两个成员和数据中心2的一个成员。If one of the members of the replica set is an arbiter, distribute the arbiter to Data Center 1 with a data-bearing member.如果副本集的一个成员是仲裁员,请将仲裁员与数据承载成员一起分发给数据中心1。
Three data centers: one member to Data Center 1, one member to Data Center 2, and one member to Data Center 3.三个数据中心:数据中心1的一个成员,数据中心2的一个,数据中心3的一个。
Distributing replica set members across two data centers provides benefit over a single data center. 跨两个数据中心分布副本集成员比单个数据中心更具优势。In a two data center distribution,在两个数据中心的分布中,
If possible, distribute members across at least three data centers. 如果可能,请将成员分布到至少三个数据中心。For config server replica sets (CSRS), the best practice is to distribute across three (or more depending on the number of members) centers. 对于配置服务器副本集(CSRS),最佳实践是分布在三个(或更多,具体取决于成员数量)中心。If the cost of the third data center is prohibitive, one distribution possibility is to evenly distribute the data bearing members across the two data centers and store the remaining member in the cloud if your company policy allows.如果第三个数据中心的成本过高,一种分布可能性是在两个数据中心均匀分布数据承载成员,如果公司政策允许,将其余成员存储在云中。
For a replica set with 5 members, some possible distributions of members include:对于具有5个成员的副本集,一些可能的成员分布包括:
Two data centers: three members to Data Center 1 and two members to Data Center 2.两个数据中心:数据中心1有三个成员,数据中心2有两个成员。
Three data centers: two member to Data Center 1, two members to Data Center 2, and one member to site Data Center 3.三个数据中心:两个成员连接到数据中心1,两个成员链接到数据中心2,一个成员连接至站点数据中心3。
Distributing replica set members across two data centers provides benefit over a single data center. 跨两个数据中心分布副本集成员比单个数据中心更具优势。In a two data center distribution,在两个数据中心的分布中,
If possible, distribute members across at least three data centers. 如果可能,请将成员分布到至少三个数据中心。For config server replica sets (CSRS), the best practice is to distribute across three (or more depending on the number of members) centers. 对于配置服务器副本集(CSRS),最佳实践是分布在三个(或更多,具体取决于成员数量)中心。If the cost of the third data center is prohibitive, one distribution possibility is to evenly distribute the data bearing members across the two data centers and store the remaining member in the cloud if your company policy allows.如果第三个数据中心的成本过高,一种分布可能性是在两个数据中心均匀分布数据承载成员,如果公司政策允许,将其余成员存储在云中。
For example, the following 5 member replica set distributes its members across three data centers.例如,以下5个成员的副本集将其成员分布在三个数据中心。
Some members of the replica set, such as members that have networking restraint or limited resources, should not be able to become primary in a failover. 副本集的某些成员,例如具有网络限制或资源有限的成员,应该无法在故障切换中成为主成员。Configure members that should not become primary to have priority 0.将不应成为主要成员的成员配置为优先级为0。
In some cases, you may prefer that the members in one data center be elected primary before the members in the other data centers. 在某些情况下,您可能更希望一个数据中心的成员在其他数据中心成员之前被选为主要成员。You can modify the 您可以修改成员的priority
of the members such that the members in the one data center has higher priority
than the members in the other data centers.priority
,使一个数据中心中的成员的priority
高于其他数据中心中成员的优先级。
In the following example, the replica set members in Data Center 1 have a higher priority than the members in Data Center 2 and 3; the members in Data Center 2 have a higher priority than the member in Data Center 3:在以下示例中,数据中心1中的副本集成员的优先级高于数据中心2和3中的成员;数据中心2中的成员的优先级高于数据中心3中的成员:
Verify that your network configuration allows communication among all members; i.e. each member must be able to connect to every other member.验证您的网络配置是否允许所有成员之间进行通信;即,每个成员必须能够连接到其他每个成员。