当前位置:网站首页>Keepalived to achieve high service availability
Keepalived to achieve high service availability
2022-06-26 06:00:00 【Interview with Java factory】
1. Keepalived summary
1.1 Keepalived What is it? ?
Keepalived Software was originally designed for LVS Designed by load balancing software , To manage and monitor LVS The status of each service node in the cluster system , Later, we added the high availability VRRP function . therefore ,Keepalived Besides being able to manage LVS Software outside , It can also be used as other services ( for example :Nginx、Haproxy、MySQL etc. ) High availability solution software .
Keepalived Software is mainly through VRRP Protocol for high availability .VRRP yes Virtual Router Redundancy Protocol( Virtual router redundancy protocol ) Abbreviation ,VRRP The purpose is to solve the problem of single point failure of static routing , It can guarantee that when individual nodes are down , The whole network can run continuously .
therefore ,Keepalived On the one hand, it has configuration management LVS The function of , At the same time, it also has the right to LVS The health check function of the following nodes , On the other hand, it can also realize the high availability function of system network service .
1.2 Keepalived Three important functions of service
management LVS Load balancing software
Realization LVS Cluster node health check
High availability as a system network service (failover)
1.3 Keepalived High availability failover principle
Keepalived Failover between pairs of highly available services , It's through VRRP (Virtual Router Redundancy Protocol, Virtual router redundancy protocol ) To achieve .
stay Keepalived When the service is working , Lord Master The node will continuously send ( The way of multicasting ) Heartbeat message , To inform for Backup Node itself still live to see , When the Lord Master When a node fails , Can't send a heartbeat message , Therefore, the standby node cannot continue to detect the arrival of autonomy Master Node's heartbeat , So call your own receiver , Take over the master Master Node IP Resources and services . And be the Lord Master When the node recovers , To prepare Backup The node will release its own takeover when the primary node fails IP Resources and services , Return to the original standby role .
What is? VRRP?
VRRP, Full name Virtual Router Redundancy Protocol, The Chinese name is virtual routing redundancy protocol ,VRRP The emergence of static routing is to solve the single point of failure problem ,VRRP It is through an election mechanism to hand over the routing task to a certain station VRRP The router .
1.4 Keepalived working principle
Keepalived High availability clusters are connected by VRRP communication , therefore , Let's get to know VRRP:
- VRRP, Full name Virtual Router Redundancy Protocol, The Chinese name is virtual routing redundancy protocol ,VRRP The emergence of static routing is to solve the single point of failure problem .
- VRRP It is through a campaign protocol mechanism to hand over routing tasks to a certain station VRRP The router .
- VRRP use IP The way of multicasting ( Default multicast address (224.0_0.18)) Realize the communication between high availability clusters .
- When working, the main node is contracted , Prepare node connection package , When the standby node can't receive the packet sent by the primary node , Start a takeover program to take over the resources of the master node . There can be multiple standby nodes , Through a priority campaign , But not so Keepalived System operation and maintenance work is a pair of .
- VRRP Encryption protocol is used to encrypt data , but Keepalived At present, the official still recommends that the authentication type and password be configured in clear text .
Keepalived How services work :
Keepalived High availability clusters are connected by VRRP Communicating ,VRRP It's through the campaign mechanism to determine who's in charge , The primary node has higher priority than the standby node , therefore , When working, the master node will get all the resources first , The standby node is waiting , When the master node is down , The standby node will take over the resources of the primary node , Then replace the primary node to provide external services .
stay Keepalived Between Service Clusters , Only the server as the master node will always send VRRP Broadcast packet , Tell him he's still alive , At this time, the standby node will not occupy the primary node , When the Lord is not available , That is, when the standby cannot listen to the broadcast packet sent by the primary node , It will start relevant services to take over resources , Ensure business continuity , The fastest connection speed can be less than 1 second .
2. Keepalived Use
2.1 install
Linux Execute command installation on the server :
yum install keepalived -y
/etc/keepalived/keepalived.conf # keepalived Service master profile
/etc/rc.d/init.d/keepalived # Service startup script
2.2 The configuration file keepalived.conf Related configuration and description
! Configuration File for keepalived
# Global configuration
global_defs {
# Load balancing flag , It should be unique in the LAN . Usually the host name .
router_id Host name
}
# Define examples
vrrp_instance VI_1 {
# Appoint keepalived Role ,MASTER Mainly ,BACKUP For the case
state MASTER
# The current in vrrp Communication network interface card ( At present centos Network card of )
interface ens33
# Appoint VRRP example ID( Virtual route number ), The scope is 0-255, Be consistent
virtual_router_id 202
# priority , The greater the numerical , The higher the priority of getting the request processed , The high priority will be MASTER.
priority 100
# Specify send VRRP Notice interval , The default is 1s(vrrp Number of seconds of multicast cycle )
advert_int 1
# Set the authentication type and password ,MASTER and BACKUP The same password must be used for normal communication
authentication {
# Specify the authentication method .PASS Simple password authentication ( recommend ),AH:IPSEC authentication ( Not recommended ).
auth_type PASS
# Specify the password to use for authentication . most 8 position .
auth_pass 2020
}
# Define the virtual ip(VIP), Can be more , Each row of a
virtual_ipaddress {
192.168.199.143
}
}
2.3 start-up
/etc/init.d/keepalived start
3. High availability
Keepalived + Nginx Configure Links :
keepalived Installation and combination nginx Configure load for high availability
Last
At the end of the article, the author collated a lot of information for you ! Include java Core knowledge points + Full set of architect learning materials and videos + Interview guide for first-line large factories + Interview Resume Template +Java Architecture, e-books, etc !
All for free , If you need a friend Just click here and download directly , Verification Code :csdn
边栏推荐
- About XXX management system (version C)
- 重载和重写
- tf.nn.top_k()
- Younger sister Juan takes you to learn JDBC -- two days' Sprint Day2
- Prototype mode, Baa Baa
- String class learning
- Gram matrix
- Household accounting procedures (First Edition)
- Test depends on abstraction and does not depend on concrete
- numpy. frombuffer()
猜你喜欢
MySQL-08
Selective Search for Object Recognition 论文笔记【图片目标分割】
Selective search for object recognition paper notes [image object segmentation]
Implementation of third-party wechat authorized login for applet
【C语言】深度剖析数据在内存中的存储
小程序第三方微信授权登录的实现
数据可视化实战:实验报告
从新东方直播来探究下小程序音视频通话及互动直播
Pytorch (environment, tensorboard, transforms, torchvision, dataloader)
电商借助小程序技术发力寻找增长突破口
随机推荐
Vs2022 offline installation package download and activation
Test depends on abstraction and does not depend on concrete
302. 包含全部黑色像素的最小矩形 BFS
numpy.exp()
Old love letters
REUSE_ ALV_ GRID_ Display event implementation (data_changed)
Force buckle 875 Coco, who likes bananas
423-二叉树(110. 平衡二叉树、257. 二叉树的所有路径、100. 相同的树、404. 左叶子之和)
怎么把平板作为电脑的第二扩展屏幕
kolla-ansible部署openstack yoga版本
05. basic data type - Dict
tf. nn. top_ k()
SSH keygen specifies the path
Status mode, body can change at will
Class and object learning
numpy.tile()
操作符的优先级、结合性、是否控制求值顺序【详解】
"= =" difference from "equals"
The difference between abstract and interface interface
C XX management system