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

Experimental Test and results of LVS load balancing

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 the experimental tests and results of LVS load balancing, hoping to give you some help in practical application. Load balancing involves a lot of things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

Install LVS1, load LVS kernel module modprobe ip_vs / / load ip_vs module cat / proc/net/ip_vs / / View ip_vs version information 2, Install LVS management tool rpm-ivh / mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm or yum install ipvsadm- yipvsadm-v / / View version LVS Scheduler-NAT mode LVS load balancing cluster-address translation mode (LVS-NAT) environment: schedule a CVM: Linux-CentOS7.4 IP address: 192.168.80.100 (intranet) 192 .168.90.100 (public network) two Web servers: Linux-CentOS7.4 IP address: 192.168.80.101 (SERVER AA) IP address: 192.168.80.102 (SERVER BB) client: take win7 as an example Used to test and verify IP address: 192.168.90.10 (public network) systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring modprobe ip_vs / / load ip_vs module cat / proc/net/ip_vs / / View ip_vs version information rpm-Q ipvsadm / / check whether to install ipvsadm installation package rpm-ivh / mnt/Packages/ipvsadm- 1.27-7.el7.x86_64.rpm or yum install ipvsadm-yipvsadm-v / / check the version ls / mnt/Packages/ | grep ipvsadm / / check whether this software package is available

Add a network card to the virtual machine

Ifconfig / / View the network card

Cd / etc/sysconfig/network-scripts/

Cp-p ifcfg-ens32 ifcfg-ens34

Vi ifcfg-ens34

After modification:

Systemctl restart network / / restart the network card

Ifconfig / / View the network card

Ipvsadm-A-t 192.168.90.103 ipvsadm 80-s rr Note: "- A" means adding virtual server "- t" to specify VIP address and TCP port "- s" to specify load scheduling algorithms-Round Robin (rr), weighted Round Robin (wrr), least connection (lc), Weighted least connection (wlc) add server node: ipvsadm-a-t 192.168.90.103mipvsadm 80-r 192.168.80.104mipvsadm-a-t 192.168.90.103mipvsadm 80-r 192.168.80.105mipvsadm 80-m Note: "- a" means adding a real server "- t" to specify the VIP address and TCP port "- r" to specify the RIP address and TCP port "- m" table Indicates that using NAT cluster mode "- g" is DR mode "- I" is TUN mode ipvsadm-Ln / / View node status

Delete the server node: ipvsadm-d-r 192.168.80.105 ipvsadm 80-t 192.168.90.103:80ipvsadm-Ln

Delete the entire virtual server: ipvsadm-D-t 192.168.90.103:80ipvsadm-Ln

Vi nat.sh #! / bin/bashecho "1" > / proc/sys/net/ipv4/ip_forward / / enable routing address translation ipvsadm-C / / clear all records in the kernel virtual server table ipvsadm-A-t 192.168.90.103 rr / / create a virtual server ipvsadm-a-t 192.168.90.103 ipvsadm 80-r 192.168.80.10480-m / / add server node ipvsadm-a-t 192.168.90.103ipvsadm 80-r 192.168.80.105ipvsadm 80-m / / add server node ipvsadm-Ln / / View node status: wq / / Save exit chmod + x nat.sh / / give nat.sh file permission. / nat.sh

On the 80.104 virtual machine, systemctl stop firewalld / / turn off the firewall setenforce 0 / / turn off the monitoring yum install httpd-y / / install httpvi / etc/httpd/conf/httpd.conf to remove the # in front of ServerName www.example.com:80 cd / var/www/html/echo "SERVER AA" > index.htmlsystemctl start httpd/ / enable http to access http://192.168.80.104 on the web

Vi / etc/sysconfig/network-scripts/ifcfg-ens32 add GATEWAY=192.168.80.103

Systemctl restart network / / restart the network card on the 80.105 virtual machine systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring yum install httpd-y / / install httpvi / etc/httpd/conf/httpd.conf remove cd / var/www/html/echo "SERVER BB" > index.htmlsystemctl start httpd/ / enable http to access http://192.168.80.105 on the web page

Vi / etc/sysconfig/network-scripts/ifcfg-ens32 add GATEWAY=192.168.80.103

Systemctl restart network / / restart the network card to access the http://192.168.90.103LVS scheduler on the web page-- the DR mode scheduler is in the same network segment as each server: scheduling server one: Linux-CentOS7.4 IP address: two 192.168.80.100Web servers: Linux-CentOS7.4 IP address: 192.168.80.101 (SERVER AA) IP address: 192.168.80. One SERVER BB client: take win7 as an example Used for testing and verification

IP address: 192.168.80.2

After reading the above experimental tests and results of LVS load balancing, 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 who 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