Get the App
SLTechnology News&Howtos  ›  Database  › 

[MongoDB Learning Notes 34] Design principles of MongoDB replica set

Shulou Source: shulou.com Published: 2022-06-01 15:06:02 10月04日 Update

There is an important concept in replica sets in MongoDB: most

Because only one node in the replica set is readable and the other nodes are only readable, while the choice of the primary node is determined by the majority, it can continue to be the primary node only when it is supported.

(1) most of the confirmation formulas for this number: M=int ((N _ 2) + 1)

* most refer to the total number of servers in the replica set that are equal to or greater than M, but less than or equal to N

(2) once most of a replica set is unavailable, the whole replica set is not available; for the case where N is an even number, 2 nodes fail and the whole replica set fails.

Primary node election mechanism:

(1) when the backup node cannot connect to the primary node, it will contact other replica set members to elect itself as the primary node.

(2) other members will first make several checks:

a. Is itself connected to the primary node?

b. Is the data of the backup node that you want to be elected as the primary node up to date?

c. Are there any other higher priority members that can be elected as the primary node?

(3) as long as a "majority" member votes against it, the election is vetoed; only the candidate gets the "majority" member's approval vote, it will become the main node.

Tags: Node copy election member only backup important number priority candidate even formula dissenting vote total situation number data server mechanism concept Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB vpn Docker Shulou Information Xiaomi