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

LVS load balancing Cluster under CentOS7.4 version-detailed explanation of Direct routing pattern

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

The following brings you a detailed explanation of the LVS load balancing cluster-direct routing pattern under the CentOS7.4 version, hoping to give you some help in practical application. Load balancing involves more things, there are not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

LVS load balancing Cluster-Direct routing pattern (LVS-DR)

Environment:

Schedule a CVM: Linux-CentOS7.4

IP address: 192.168.80.20

Two Web servers: Linux-CentOS7.4

IP address: 192.168.80.30 (SERVER AA)

IP address: 192.168.80.40 (SERVER BB)

Client 1: take win7 as an example for testing and verification

IP address: 192.168.80.2

Step 1: configure the scheduling server

/ / load LVS kernel module

LVS, which is now part of the Linux kernel, is compiled as an ip_vs module by default and can be invoked automatically if necessary. You can manually load the ip_vs module and view the version information of the ip_vs module on the current system by doing the following

[root@localhost ~] # modprobe ip_vs / / load ip_vs module

[root@localhost ~] # cat / proc/net/ip_vs

/ / install the management software ipvsadm, no need to start it

[root@localhost] # rpm-ivh / mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm

/ / Edit the scheduling server script

[root@localhost ~] # vi dr.sh

#! / bin/bash

#

Ifconfig ens33:0 192.168.80.100 broadcast 192.168.80.100 netmask 255.255.255.255 up / / add a virtual interface for a virtual address

Route add-host 192.168.80.100 dev ens33:0 / / add routes to ens33:0

Ipvsadm-C / / clears all records in the kernel virtual server table

Ipvsadm-A-t 192.168.80.100 ipvsadm 80-s rr / / create a virtual server

Ipvsadm-a-t 192.168.80.100 ipvsadm 80-r 192.168.80.30 purl 80-g / / add server node

Ipvsadm-a-t 192.168.80.100 ipvsadm 80-r 192.168.80.40 purl 80-g / / add server node

Ipvsadm-Ln / / View node status and add "- n" to display address and port information in numeric form

Save exit

/ / option Notes:

"- A" means to add a virtual server

"- a" means to add a real server

"- t" is used to specify VIP address and TCP port

"- r" is used to specify the RIP address and TCP port

"- s" is used to specify load scheduling algorithms-rr (polling), wrr (weighted polling), lc (minimum connections), wlc (weighted least connections)

"- m" indicates using NAT cluster mode ("- g" is DR mode, "- I" is TUN mode)

/ / execute the script

[root@localhost ~] # sh dr.sh

/ / View virtual interface

[root@localhost ~] # ifconfig

Step 2: configure the Web server

Configure the SERVER AA server (192.168.80.30)

-configure http service-

/ / install http service

[root@aa ~] # yum install-y httpd

/ / Edit the main configuration file

[root@aa ~] # vi / etc/httpd/conf/httpd.conf

ServerName aa / / remove the "#" number and modify the host name

Save exit

/ / configure the default display web page

[root@aa ~] # cd / var/www/html/

[root@aa html] # echo "SERVER AA" > index.html

[root@aa html] # service httpd start / / restart the http service

/ / win7 verifies the http service

Visit http://192.168.80.30

-configure DR mode-

[root@aa ~] # vi web.sh

#! / bin/bash

#

Ifconfig lo:0 192.168.80.100 broadcast 192.168.80.100 netmask 255.255.255.255 up

Route add-host 192.168.80.100 dev lo:0

Echo "1" > / proc/sys/net/ipv4/conf/lo/arp_ignore

Echo "2" > / proc/sys/net/ipv4/conf/lo/arp_announce

Echo "1" > / proc/sys/net/ipv4/conf/all/arp_ignore

Echo "2" > / proc/sys/net/ipv4/conf/all/arp_announce

Sysctl-p & > / dev/null

Save exit

[root@aa ~] # sh web.sh / / execute script

[root@aa ~] # ifconfig / / View virtual interface

Configure the SERVER BB server (192.168.80.40)

-configure http service-

/ / install http service

[root@bb ~] # yum install-y httpd

/ / Edit the main configuration file

[root@bb ~] # vi / etc/httpd/conf/httpd.conf

ServerName bb / / remove the "#" number and modify the host name

Save exit

/ / configure the default display web page

[root@bb ~] # cd / var/www/html/

[root@bb html] # echo "SERVER BB" > index.html

[root@bb html] # service httpd start / / restart the http service

/ / win7 verifies the http service

Visit http://192.168.80.40

-configure DR mode-

[root@bb ~] # vi web.sh

#! / bin/bash

# hehe

Ifconfig lo:0 192.168.80.100 broadcast 192.168.80.100 netmask 255.255.255.255 up

Route add-host 192.168.80.100 dev lo:0

Echo "1" > / proc/sys/net/ipv4/conf/lo/arp_ignore

Echo "2" > / proc/sys/net/ipv4/conf/lo/arp_announce

Echo "1" > / proc/sys/net/ipv4/conf/all/arp_ignore

Echo "2" > / proc/sys/net/ipv4/conf/all/arp_announce

Sysctl-p & > / dev/null

Save exit

[root@bb ~] # sh web.sh / / execute script

[root@bb ~] # ifconfig / / View virtual interface

Step 3: verify the test

Win7 visits http://192.168.80.100 to open a few more tasks

/ / verify successfully

Read the above detailed explanation of LVS load balancer cluster-direct routing pattern under CentOS7.4 version. If you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.

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