Home  >  Article  >  Database  >  How are new master nodes generated?

How are new master nodes generated?

藏色散人
藏色散人Original
2020-07-01 10:53:542101browse

The new master node is elected and implemented based on the "leader election" method of the Raft algorithm; each master node responsible for processing slots in the cluster has a chance to vote, and the first A slave node that requests a vote from the master node will receive the vote from the master node.

How are new master nodes generated?

Elect a new master node

The new master node is elected through electionGenerated, implementation of leader election method based on Raft algorithm

  • Every master node responsible for processing slots in the cluster has a chance to vote, and the first one to vote The slave node that the master node requests to vote will get the vote of the master node

  • When the slave node finds that the master node it is replicating has entered the offline state, the slave node will broadcast a message to the cluster, All master nodes with voting rights that have received the message are required to vote for this slave node

  • The master node with voting rights has not yet voted for other nodes, then the master node will respond to the message, indicating that the master node Support slave nodes to become new master nodes

  • Each slave node participating in the election receives a message and counts how many master nodes it has supported

  • If the cluster has N master nodes with voting rights, then when a slave node collects 1 support vote greater than or equal to N/2, the slave node will be selected as the new master node

  • If the slave node does not collect enough support votes, the cluster will be elected again until a new master node is elected

Related learning recommendations: redis Tutorial

The above is the detailed content of How are new master nodes generated?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn