当前位置:网站首页>Master and backup role election strategy in kept
Master and backup role election strategy in kept
2022-07-03 11:49:00 【Brother Xing plays with the clouds】
stay Keepalived colony in , In fact, there is no strict sense of the Lord 、 For the node , Although you can Keepalived Set... In the configuration file “state” The options are “MASTER” state , However, this does not mean that this node has always been Master role . The role of the control node is Keepalived In the configuration file “priority” value , But it does not control the role of all nodes , Another way to change the role of nodes is in vrrp_script Module “weight” value , Both options correspond to an integer value , among “weight” The value can be a negative integer , A node is at colony The role in is determined by the size of these two values .
One active and multiple standby Keepalived colony in ,“priority” The one with the largest value will be the one in the cluster Master node , And everything else is Backup node . stay Master After the node fails ,Backup Between nodes “ Democratic elections ”, By setting the node priority value “priority” and ““weight” The calculation of , Select new Master The node takes over the cluster service .
stay vrrp_script Module , If not set “weight” Option value , Then the cluster priority will be selected by Keepalived In the configuration file “priority” Values determine , When it is necessary to flexibly control the priority in the cluster , It can be done by vrrp_script Set in the module “weight” It's worth it . Here is an example to illustrate .
Suppose there is A and B Two nodes Keepalived colony , stay A node keepalived.conf In file , Set up “priority” The value is 100, And in the B node keepalived.conf In file , Set up “priority” The value is 80, also A、B Both nodes use “vrrp_script” Module to monitor MySQL service , At the same time “weight” The value is 10, Then the following will happen .
Start on both nodes Keepalived After service , The normal situation is A Nodes will become Master node , and B Automatically become Backup node , At this time will be A Node mysql Service closing , Discover by looking at the log , It didn't show up B Node takeover A Log of node ,B The node is still in Backup state , and A The node is still Master state , In this case, the whole HA Cluster will lose its meaning .
Now let's analyze the reasons for this situation , This is the same. Keepalived Master in cluster 、 Prepare for the problem of role election strategy . The following is a summary of Keepalived Use in vrrp_script Module is the election algorithm of the whole cluster role , because “weight” The value can be positive or negative , therefore , There are two situations to explain .
1. “weight” When the value is positive
stay vrrp_script If the script specified in is detected successfully , that Master The weight of the node will be “weight Value and ”priority“ Sum of values , If script detection fails , that Master The weight of the node remains “priority” value , Therefore, the switching strategy is :
Master node “vrrp_script” When script detection fails , If Master node “priority” Less than Backup node “weight Value and ”priority“ Sum of values , The main 、 Standby switching .
Master node “vrrp_script” When the script detection is successful , If Master node “weight” Value and “priority” The sum of values is greater than Backup node “weight” Value and “priority” Sum of values , The master node is still the master node , No switching .
2. “weight” When the value is negative
stay “vrrp_script” If the script specified in is detected successfully , that Master The weight of the node is still “priority” value , When script detection fails ,Master The weight of the node will be “priority“ Value and “weight” The difference in value , Therefore, the switching strategy is :
Master node “vrrp_script” When script detection fails , If Master node “priority” Value and “weight” The difference between values is less than Backup node “priority” value , The main 、 Standby switching .
Master node “vrrp_script” When the script detection is successful , If Master node “priority” Greater than Backup node “priority” When the value of , The master node is still the master node , No switching .
In familiar with Keepalived Lord 、 Prepare for the role of the election strategy , Let's analyze the example just now , because A、B Two nodes are set “weight” Values are 10, Therefore, the first kind of election strategy , stay A Nodes stop Mysql After service ,A Script detection of the node will fail , here A The weight of the node will remain A Set on the node “priority” value , That is to say 100, and B The weight of the node will change to “weight” Value and “priority” Sum of values , That is to say 90(10+80), That's what happened A The node weight is still greater than B Node weights , Therefore, there will be no master 、 Standby switching .
about “weight” Value settings , There is a simple criterion , namely “weight” The absolute value of value should be greater than Master and Backup node “priority” The difference in value . For the top A、B Examples of two nodes , Just set “weight” Greater than 20 It can ensure the normal operation and switching of the cluster . thus it can be seen , about “weight Value settings , Be very careful , If the settings are not good , Will cause the cluster role election to fail , Paralyze the cluster .
边栏推荐
- R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
- OpenStack中的测试分类
- 剑指offer专项32-96题做题笔记
- 牛牛的组队竞赛
- Arctangent entropy: the latest SCI paper in July 2022
- R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
- 《剑指offer 04》二维数组查找
- Yintai department store ignites the city's "night economy"
- 外插散点数据
- typeScript
猜你喜欢

AOSP ~ NTP ( 网络时间协议 )

rxjs Observable filter Operator 的实现原理介绍

The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.

Web security summary

VS2015的下载地址和安装教程

(数据库提权——Redis)Redis未授权访问漏洞总结

Slam mapping and autonomous navigation simulation based on turnlebot3

软件测试周刊(第78期):你对未来越有信心,你对现在越有耐心。

Analysis of EPS electric steering system

C language AES encryption and decryption
随机推荐
P3250 [hnoi2016] Network + [necpc2022] f.tree path tree section + segment tree maintenance heap
Momentum of vulnhub
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Excel表格转到Word中,表格不超边缘纸张范围
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
Phpcms prompt message page Jump to showmessage
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
Slam mapping and autonomous navigation simulation based on turnlebot3
在CoreOS下部署WordPress实例教程
Nestjs configuration service, configuring cookies and sessions
Vulnhub narak
量化计算调研
软考中级软件设计师该怎么备考
Modular programming of single chip microcomputer
Sheet1$.输出[Excel 源输出].列[XXX] 出错。返回的列状态是:“文本被截断,或者一个或多个字符在目标代码页中没有匹配项。”。
Web安全总结
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
DNS多点部署IP Anycast+BGP实战分析
如何将数字字符串转换为整数