Replica Set

A replica set consists of a set of mongod processes. It is a collection of nodes that help ensure data redundancy and reliability.

For details about the mongod process, see the MongoDB official document.

A replica set consists of three nodes: primary, secondary, and hidden. The three-node architecture is set up automatically, and the three nodes automatically synchronize data with each other to ensure data reliability.

You can perform operations on the primary and secondary nodes. If a primary node goes down or becomes faulty, the replica set elects a secondary node as a new primary node and continues normal operations. If there are no secondary nodes available, a hidden node will take over the role of the secondary node to ensure high availability. The following figure shows the replica set architecture.

Figure 1 Replica set architecture