Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[distributed] Leader Election for Zookeeper-introduction to the Election process

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

[distributed] Leader Election in Zookeeper-the election process introduces the beginning of the election, where each server has a vote and will vote for itself to be elected Leader. After the poll is completed, the voting information is sent to all servers in the cluster (the observer server does not participate in the election).

The ballot consists of two parts: the server uniquely identifies the myid and the transaction number zxid, namely (myid,xzid).

The larger the zxid, the newer the data and the greater the weight in the selection algorithm.

The larger the myid, the greater the weight in the selection algorithm.

When comparing the votes, it will first compare the zxid,zxid big winner, when the zxid is the same, the bigger myid,myid will win, the winner's vote will remain the same, the loser's vote will become the same as the winner's, and the vote will be sent out again.

When more than half of the machines receive the same voting information, Leader is selected and the election is over.

For example:

There are three servers in the campaign, myid: 1, 2, 3, Zxid: 9, 9, 8, respectively.

The election process is as follows:

A received ballots (2jue 9), (3jue 8). Compared with his own (1rem 9), the ballots were changed to (2jue 9) and cast.

The votes received by B are (1) and (3), respectively. Compared with his (2), the result remains the same.

The votes received by C are (1) and (2) respectively. Compared with their own (3), the votes are changed to (2) and cast.

At this time, Machine B has more than half of the votes and is elected Leader.

As you can see from the above rules, the newer the data on that server (the larger the ZXID will be), the more likely it is to become a Leader, and the more guaranteed the data can be recovered. If the ZXID is the same, the larger the myid, the greater the chance.

Reference:

Http://www.cnblogs.com/leesf456/p/6107600.html

Https://www.cnblogs.com/yuyijq/p/4116365.html

Http://www.cnblogs.com/ASPNET2008/p/6421571.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 236

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report