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

High availability of Keepalived+Lvs-DR

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Keepalived High availability

Keepalived+LVS-DR pattern topology diagram:

LVS: is the middleware software (that is, proxy server software), is used to achieve cluster load balancing.

+ +-> + Client + 192.168.11.1 win7/10 | + | _ _ | _ | | VIP eth0:1 192.168.10.100 | | + + | | + Director master Master node11 + + Director backup Slave node12 + | DIP 192.168.11.11 ens33 Nic DIP 192.168.11.12 ens33 Nic | _ | + +-+ RealServer A node13 + + RealServer B node14 + 192.168.11.13 Universe 24 192.168.11.14 Universe 24

Deploy floating resources (VIP IPVS policy) on Director master and Director backup respectively

Both Director tested work fine in DR mode. Remove floating resources after the test is complete.

First of all: install keepalived and ipvsadm software packages on node11 and node12 respectively, and configure keepalived.

Install and configure Keepalived on Director master

Yum install keepalived ipvsadm-ycp-av / etc/keepalived/keepalived.conf {, .bak} back up the original configuration file vim / etc/keepalived/keepalived.conf

! Configuration File for keepalived

Global_defs {Global definition, description: in the experimental test environment, the following can be written freely, but the router_id of master and backup must be the same

Notification_email {set up notification mailbox

Email address of the root@localhost administrator

}

The sender mailbox of the notification_email_from keepalived@localhost notification message

Smtp_server 127.0.0.1 Mailbox server IP address

Smtp_connect_timeout 30 mail server connection timeout is 30 seconds

Router_id dr1 router ID name, the ID names of master and backup in the same keepalived high availability cluster must be the same

# vrrp_strict must comment out this line, otherwise the scheduler cannot be accessed through the VIP address

}

Vrrp_instance VI_1 {instance settings of vrrp virtual routing redundancy protocol, instance name is VI_1

State MASTER status. Master is MASTER and slave is BACKUP.

Interface ens33 / / heartbeat detection network card interface. Write the network card interface name according to the actual situation, and use ip a to check the network card interface name.

Virtual_router_id 51 / / Master master and backup must be the same on both sides. Here is the group number of the cluster

Priority 100 / / priority, the value of MASTER must be higher than the value of BACKUP, similar to the number of votes in real-life elections

Advert_int 1 / / check interval (in seconds). The multicast address of vrrp is 224.0.0.18

Authentication {Authentication configuration

Auth_type PASS / / authentication type is password, master / slave should be consistent

The auth_pass 1111 / / authentication password is 1111, and the master / slave must be consistent.

}

Virtual_ipaddress {

192.168.11.100 / / VIP, can have multiple IP, one IP address per line

192.168.11.111

}

}

Virtual_server 192.168.11.100 80 {/ / LVS configuration (that is, the scheduler configuration), this line is equivalent to the ipvsadm-At 192.168.11.100 ipvsadm 80-s wrr command

Delay_loop 3 / / time interval between service inquiries

Lb_algo wrr / / LVS scheduling algorithm

Lb_kind DR / / LVS cluster mode

Protocol TCP / / specifies the protocol as TCP protocol

Real_server 192.168.11.13 80 {/ / the IP and port number of the real server on the RS backend, which is equivalent to the ipvsadm-at 192.168.11.100 ipvsadm 80-r 192.168.11.13 IP 80-g-w 1 command

Weight 1

TCP_CHECK {/ / RS health check. If the port 80 service on the RS host is shut down abnormally, the IP information of this RS cannot be found with ipvsadm-Ln.

Connect_timeout 3 / / connection timeout is 3 seconds

}

}

Real_server 192.168.11.14 80 {

Weight 1

TCP_CHECK {

Connect_timeout 3

}

}

}

Cd / etc/keepalivedscp keepalived.conf 192.168.11.12:/etc/keepalived/ sends the configuration file to the host of node12

After copying, modify the configuration file

State BACKUP

Priority 90

Start the service on the two Director (scheduler) and look at the vip address:

Systemctl restart keepalived [centos 7 Special commands] service keepalived restart [centos 6 and 7 General commands] ip a can be seen on the master that the ens33 network card has two VIP addresses, 192.168.11.100 and 192.168.11.111. There is no VIP on the backup slave host. When you use systemctl stop keepalived on master, you will have these two VIP on the slave host. Ipvsadm-Ln to check the cluster configuration information of ipvs

= =

Grab the bag:

Yum install-y tcpdumptcpdump-I ens33-nv vrrp

-I specify the network card

-n is displayed digitally (ip,port)

-v display details

-vv displays more detailed information

-w Save to file

The role of keepalived for multicast over the vrrp protocol:

It is to elect which keepalived host will take over the business (using VIP). Whoever has the highest priority priority (that is, more votes) will have an VIP address.

When both master and backup are running the keepalived service:

Multicast messages sent by node11 (master):

Src:192.168.11.11

Dest:224.0.0.18

Multicast information received by node12 (backup):

Src:192.168.11.11

Dest:224.0.0.18

When the node11 master stops the keepalived service:

Multicast messages sent by node12:

Src:192.168.11.12

Dest:224.0.0.18

Multicast information received by other hosts in the keepalived cluster:

Src:192.168.11.12

Dest:224.0.0.18

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