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

Keepalived dual Hot standby Theory of centos 7 + configuration document

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

1. Working principle and function of keepalived:

Keepalived was originally a powerful assistive tool designed specifically for LVS, mainly to provide failover and health check

Check function-judge the availability of LVS load scheduler and node server, isolate and replace it with new server in time.

The disabled host replies and rejoins the cluster. If the LVS environment is deployed separately, if the scheduler goes down, the whole cluster

Invalid, when a web node goes down, the client will always encounter the situation that the web page cannot be accessed, so, the

Keepalived and LVS combine to form a truly highly available cluster, and of course, shared storage at the back end must also be

To build a highly available storage server, one of the three can not be satisfied, and none of them can be called a highly available cluster ring.

Environment.

Keepalived official website: keepalived official website, in non-LVS environment, keepalived can also be used as hot backup software

Use.

Keepalived adopts VRRP (Virtual routing redundancy Protocol) hot backup protocol to realize the Linux server's

Multi-machine hot standby. VRRP is a backup solution for routers-- multiple routers form a hot backup group.

Shared virtual IP (VIP) addresses provide services; only one primary router in each hot backup group provides services at a time.

For service, other routers are in a redundant state. If the current online router fails, the other routers will automatically take over.

(priority determines succession order) virtual IP address to continue to provide services.

Each router in the hot standby group may become the primary router, and the IP address (VIP) of the virtual router can be in the hot standby group.

The router transfers, so it is also called a drift IP address. When using keepalived, the implementation of the drift address does not need to be manual

Establish a virtual interface profile, such as ens33:0, which is automatically managed by keepalived based on the profile.

Based on VRRP hot backup mode, keepalived can be used as server failover, and each hot backup group can have multiple servers.

Server-the most commonly used is multi-computer hot standby. In this multi-machine hot standby scheme, the failover is mainly aimed at the virtual IP address

Drift to achieve. Therefore, it can be applied to a variety of application servers (whether it is Web, FTP, Mail, SSH, DNS....).

2. Detailed explanation of keepalived dual-machine hot backup configuration:

Through the following simple environment diagram, you can have a comprehensive understanding of the configuration and functions of dual-computer hot backup:

1. Configure the master server:

[root@lVS1 ~] # systemctl stop firewalld # turn off the firewall [root@lVS1 ~] # yum-y install keepalived ipvsadm installation tools [root@lVS1 ~] # systemctl enable keepalived # set up self-boot [root@lVS1 ~] # cd / etc/keepalived/ [root@lVS1 keepalived] # cp keepalived.conf keepalived.conf.bak # backup configuration file [root@lVS1 keepalived] # vim keepalived.conf # Edit configuration file global_defs {notification_email {acassen@firewall.loc # enable mail notification The recipient address is set here, and you can configure multiple failover@firewall.loc sysadmin@firewall.loc} notification_email_from Alexandre.Cassen@firewall.loc # sender names, addresses smtp_server 192.168.200.1 smtp_connect_timeout 30 router_id LVS_DEVEL1 # the name of this server (which must be unique in the cluster). . # omit part} vrrp_instance VI_1 {# defines the hot backup status of VRRP hot backup instance state MASTER #. MASTER represents the ID number of the physical interface virtual_router_id 51 # virtual router on which the primary server (note case) interface ens33 # carries the VIP address, and each hot backup group remains the same. Priority 100 # priority is 0-100. the higher the number, the more priority. The number of seconds between advert_int 1 # announcements (heartbeat rate). Authentication {# authentication information, each hot backup group is consistent with auth_type PASS # authentication type auth_pass 1111 # password string} virtual_ipaddress {# specify drift address There can be more than one 192.168.1.100}. # omit part of the content

After confirming that the above configuration is correct, then start the keepalived service. The master server with the actual status of MASTER will automatically add the VIP address for the ens33 interface, which can be viewed by the ip command (Note: the ifconfig command is not visible).

[root@lVS1 keepalived] # systemctl start keepalived # start the service [root@lVS1 keepalived] # ip a show dev ens33 # View ens33 API 2: ens33:

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.

Share To

Servers

Wechat

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

12
Report