1, the principle of the replica set
The principle of the replica set is similar to the master-slave, the only difference is that when the primary node fails, the master-slave server will not automatically become the primary server, but to manually modify the configuration. But the sub-table set is not used, it will automatically select a server to do the primary node, so as to ensure the stability of the system.
2, how is the new master node of the replica set elected?
is through the bully algorithm, that is, the consistency protocol. Specific as follows
1): When the primary node is hung, the replica set gets the other last update time from the node compared to the main service
2): If all the last update time from the node is very old, then the election will stop
3): If most of the servers in the replica set are hung, and the primary node is included, then the election stops
4): If none of the above occurs, then update time is the most recent election to the main node
5): If the update time is the same, then who is the fastest to become the main node who is the primary node
Note: The node of the parameter election must be more than half the nodes in the replica set
3. Roles for each node in the replica set