当前位置:网站首页>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 .
边栏推荐
- Machine learning 3.2 decision tree model learning notes (to be supplemented)
- Use typora to draw flow chart, sequence diagram, sequence diagram, Gantt chart, etc. for detailed explanation
- The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
- AI模型看看视频,就学会了玩《我的世界》:砍树、造箱子、制作石镐样样不差...
- 量化计算调研
- Kubernetes 三打探针及探针方式
- R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
- After using the thread pool for so long, do you really know how to reasonably configure the number of threads?
- How should intermediate software designers prepare for the soft test
- 利用Zabbix动态监控磁盘I/O
猜你喜欢
STL Tutorial 9 deep copy and shallow copy of container elements
PHP Basics
抓包整理外篇fiddler———— 会话栏与过滤器[二]
软考中级软件设计师该怎么备考
STL教程10-容器共性和使用场景
STL教程9-容器元素深拷贝和浅拷贝问题
Kibana~Kibana的安装和配置
Machine learning 3.2 decision tree model learning notes (to be supplemented)
Viewing binary bin files with notepad++ editor
ASP. Net hotel management system
随机推荐
软考中级软件设计师该怎么备考
Yintai department store ignites the city's "night economy"
STL tutorial 10 container commonalities and usage scenarios
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
How should intermediate software designers prepare for the soft test
Phpcms prompt message page Jump to showmessage
The excel table is transferred to word, and the table does not exceed the edge paper range
836. 合并集合(DAY 63)并查集
repo ~ 常用命令
Concurrent programming - singleton
Viewing binary bin files with notepad++ editor
Key switch: press FN when pressing F1-F12
Spl06-007 air pressure sensor (example of barometer)
Repo ~ common commands
Solicitation for JGG special issue: spatio-temporal omics
Xml的(DTD,xml解析,xml建模)
同事写了一个责任链模式,bug无数...