In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how the high availability architecture of Keepalived based on VIP is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
1. Introduction to Keepalived. 1. The role of keepalived
The purpose of Keepalived is to detect the status of the server. If a web server goes down or fails, Keepalived will detect and remove the faulty server from the system, and use other servers to replace the work of the server. When the server is working normally, Keepalived will automatically load the server into the server farm, all these tasks will be completed automatically, without human intervention, all you need to do is to repair the faulty server.
2. Characteristics of Keepalived
The configuration file is simple: the configuration file is relatively simple, and the high availability feature can be achieved through simple configuration.
Strong stability: keepalived is a software similar to layer3/4/7 switch mechanism, which has the functions of layer 3, layer 4 and layer 7 switches. It is often used for highly available services of front-end load balancers. When the main server fails, it can switch quickly, the monitoring mechanism is flexible, and the success rate is high.
Low cost: open source software, you can download the configuration directly, there is no extra charge.
Wide range of applications: because keepalived can be applied at many levels, it can be highly available for almost all applications, including LVS, database, http services, nginx load balancing and so on.
Multiple types are supported: master-slave mode is supported, master-master mode is highly available, and can be flexibly selected according to business scenarios.
2. How Keepalived works. 1. The internal work of Keepalived is divided into the following parts
WatchDog monitors the status of checkers and VRRP processes.
Checkers is responsible for the health check healthchecking of the real server.
VRRP Stack is responsible for failed switching between load balancers.
IPVS wrapper is used to send set rules to kernel IPVS code.
Netlink Reflector is used to set the vip address of vrrp, etc.
2. VRRP protocol
Keepalived is based on VRRP protocol, and VRRP is called Virtual Router Redundancy Protocol, that is, virtual routing redundancy protocol.
VRRP determines the role of each router in the virtual router (Master router or Backup router) based on priority. The VRRP priority ranges from 0 to 255. the higher the value, the higher the priority, and the configurable range is from 1 to 254. priority 0 is used when the system is reserved for the router to relinquish the Master location, and 255 is reserved for the IP address owner. The higher the priority, the more likely it is to become a Master router. When two routers with the same priority compete for Master at the same time, compare the interface IP address size. The one with the largest interface address is selected as Master.
3. Main module
Core module: the core of keepalived, which is responsible for the startup and maintenance of the main process and the loading and parsing of global configuration files.
Check module: responsible for health check, including a variety of common check-up methods.
Vrrp module: to implement the VRRP protocol.
3. Keepalived application scenario 1. There are four important protocols running at the network layer and the data link layer.
IP: Internet protocol.
ICMP: Internet control message protocol.
ARP: address translation protocol.
RARP: reverse address translation protocol.
two。 Network layer scenario
The most common way for Keepalived to work in the network layer is to send an ICMP packet to that node in the server cluster through the ICMP protocol (similar to the function implemented by ping). If a node does not return a response packet, then the node is considered to have failed, and Keepalived will report the node failure and remove the failed node from the server cluster.
3. Transport layer scenario
In the transport layer, two main protocols are provided: the transmission control protocol TCP and the user data protocol UDP. The transmission control protocol TCP can provide reliable data transmission services, and the IP address and port represent a connector of the TCP. To obtain TCP services, a connection needs to be established on one port of the transmitter and one port of the receiver.
In the transport layer, Keepalived uses the port connection and scanning technology of TCP protocol to determine whether the cluster point is normal or not. For example, for common WEB service default port 80, SSH service default port 22, etc., once Keepalived detects that these ports do not respond to data return at the transport layer, it will assume that these ports have an exception, and then force the node corresponding to this port to be removed from the server cluster group.
4. Application layer scenario
In the application layer, different types of high-level protocols such as FTP, TELNET, HTTP, DNS and so on can be run.
The way Keepalived runs in the application layer is also more comprehensive and complicated, and users can customize the way Keepalived works; for example, users can run keepalived by writing programs. Keepalived will check whether various programs or services are running properly according to the user's settings. If the test results of Keepalived are inconsistent with the user settings, Keepalived will remove the corresponding services from the server.
4. Cluster
A cluster is a group of independent computers interconnected through a high-speed network that form a group and are managed in a single system mode. When a customer interacts with a cluster, the cluster is like an independent server.
Through the cluster technology, we can obtain relatively high benefits in terms of performance, reliability and flexibility at a lower cost, and its task scheduling is the core technology in the cluster system.
After the formation of the cluster, multiple computers and combinations can be used for massive request processing (load balancing), so as to achieve high processing efficiency, and multiple computers can also be used for backup (high availability). So that any one of the computers can break down the whole system can still run normally. Cluster is a necessary technology for Internet companies at present, which greatly improves the availability and scalability of Internet business.
5. High availability
HA (High Available), high availability clusters are measured by system reliability (reliability) and maintainability (maintainability).
In engineering, the mean time between failures (MTTF) is usually used to measure the reliability of the system, and the mean maintenance time (MTTR) is used to measure the maintainability of the system. So availability is defined as: HA=MTTF/ (MTTF+MTTR) * 100% (mean time between failures / total time, total time = average time between failures + average time to repair).
Specific HA (availability) metrics:
99% of the downtime is no more than 4 days a year.
99.9% of the downtime is no more than 10 hours a year.
99.99% of the downtime is no more than 1 hour a year.
99.999% of the downtime is no more than 6 minutes a year.
6. High availability cluster implementation
Highly available mode of work
Master-slave mode (asymmetric mode)
Duplex mode (mutual backup and mutual assistance)
Cluster working mode (multi-server mutual backup mode)
Highly available resource classification
High availability of network (user-> computer room, computer room intranet)
Server highly available (CPU, memory, disk)
High availability of storage (relational database, distributed cache, distributed storage system)
High availability of services, etc. (Web services: Nginx, DNS, CDN, etc.)
Open source high availability solution
Keepalived: address drift is achieved by implementing the vrrp protocol.
7. High availability Architecture 1. Master-slave highly available architecture
In the system, there is a Master node and a Backup node, in which the Master node provides services for online services, and the heartbeat is maintained between the Backup and Master nodes.
When the Master node is unavailable due to downtime, the system will switch to the Backup node to go online and provide services.
When the down Master node is restored, the system joins the cluster as a Backup of the Master node.
two。 Dual master high availability architecture
In the system, there are two Master nodes, both of which provide services for online services, and the two Master nodes maintain a heartbeat.
When a Master node is unavailable due to downtime, the system will direct all traffic to the remaining Master nodes and continue to provide services.
When the down Master node is restored, the system joins the Master cluster to provide services.
8. The solution of Keepalived high availability cluster
After Keepalived starts on a node, it generates a Master main process, which in turn generates two child processes, namely:
VRRP Stack: implements the VRRP protocol.
Checkers: check the health status of the ipvs backend realserver.
After both VRRP nodes are started, in order to achieve state transition, at the beginning of startup, the initial state is BACKUP, and then send notifications to other nodes, as well as their own priority information. Whoever has a high priority will be converted to MASTER, otherwise it will still be BACKUP.
At this time, the service starts on the node with the status of MASTER to provide services for users. If the node dies, it is converted to BACKUP, and the priority is reduced. The other node is converted to MASTER, and the priority is raised. The service is started on this node, and both VIP and VMAC will be transferred to this node to provide services for users.
On the VIP-based Keepalived high availability architecture is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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: 0
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.