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

Two methods of LVS Scheduler

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

Share

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

Method 1: LVS scheduler-- one NAT mode scheduling server: Linux-CentOS7.4 IP address: 192.168.80.100 (internal network) 192.168.90.100 (external 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-ivh / mnt/Packages/ipvsadm-1.27-7.el7.x86_64.rpm or Yum install ipvsadm-yipvsadm-v / / View the version

Ls / mnt/Packages/ | grep ipvsadm / / check whether this software package is available

Ifconfig / / check the network card

Add a VMnet2 (host-only mode) Nic

Ifconfig / / check to see if the network card has been added

Cd / etc/sysconfig/network-scripts/cp-p ifcfg-ens32 ifcfg-ens34 / / copy an ens32 file and change the name to ens34vi ifcfg-ens34 / / into the ens34 file

Replace it with PROXY_METHOD=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens34DEVICE=ens34ONBOOT=YESIPADDR=192.168.90.100PREFIX=24IPV6_PRIVACY=no:wq / / Save exit systemctl restart network / / restart the network card ifconfig / / check whether the network card has been modified

Ipvsadm-A-t 192.168.90.100 ipvsadm 80-s rr Note: "- A" means adding virtual server "- t" to specify VIP address and TCP port "- s" to specify load scheduling algorithm-rr, wrr, lc, Wlcipvsadm-a-t 192.168.90.100 wlcipvsadm 80-r 192.168.80.101purl 80-m / / add server node ipvsadm-a-t 192.168.90.100 ipvsadm 80-m / / add server node ipvsadm-port / add "- n" to display address and port information in numeric form

Cd / / back to the root directory ipvsadm-d-r 192.168.80.102 ipvsadm 80-t 192.168.90.100 ipvsadm 80 / / Delete 102server node ipvsadm-port / / add "- n" to display address and port information in numeric form

Ipvsadm-D-t 192.168.90.100 ipvsadm-Ln / / add "- n" to display address and port information in numeric form

Vi nat.sh / / create and enter the nat.sh file #! / 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.100bin/bashecho 80-s rr / / create a virtual server ipvsadm-a-t 192.168.90.100purl 80-r 192.168 .80.101Ln:wq 80-m / add server node ipvsadm-a-t 192.168.90.100 ipvsadm 80-r 192.168.80.102 Ln:wq / / View node status chmod-Ln:wq / / Save exit chmod + x nat.sh / / give nat.sh file permission. / nat.sh

On the 80.101 virtual machine, systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring yum install httpd-y / / install httpdvi / etc/httpd/conf/httpd.confServerName www.example.com:80 / / find this line and remove #

: wq / / Save exit cd / var/www/html/echo "SERVER AA" > index.htmlsystemctl start httpd / / restart httpdvi / etc/sysconfig/network-scripts/ifcfg-ens32 add GATEWAY=192.168.80.100 on the last line

Systemctl start httpd/ / restart httpdsystemctl restart network / / restart the network card on the 80.102 virtual machine systemctl stop firewalld / / close the firewall setenforce 0 / / close the monitoring yum install httpd-y / / install httpdvi / etc/httpd/conf/httpd.confServerName www.example.com:80 / / find this line and remove #

: wq / / Save exit cd / var/www/html/echo "SERVER BB" > index.htmlsystemctl start httpd / / restart httpdvi / etc/sysconfig/network-scripts/ifcfg-ens32 add GATEWAY=192.168.80.100 on the last line

Systemctl start httpd / / restart httpdsystemctl restart network / / restart the network card

Enter 192.168.90.100 for the web page

Method 2: LVS scheduler-- one DR mode scheduling server: 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.102 (SERVER BB) client: take win7 as an example Used for testing and verifying IP address: 192.168.80.280.100 virtual machine restore 80.100 virtual machine to snapshot on the basis of method 1 systemctl stop firewalld / / turn off firewall setenforce 0 / / turn off monitoring modprobe ip_vsyum install ipvsadm-yipvsadm-vvi dr.shroud Binchfconfig ens32:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 uproute add-host 192.168 .80.188 dev ens32:0ipvsadm-Cipvsadm-A-t 192.168.80.188 rripvsadm 80-s rripvsadm-a-t 192.168.80.188 rripvsadm 80-r 192.168.80.101 rripvsadm 80-gipvsadm-a-t 192.168.80.188 gipvsadm 80-r 192.168.80.102 rripvsadm 80-Ln:wqchmod + x dr.sh./dr.shifconfig

80.102 virtual machine

Vi web.shroudanxambinapash bashparts ifconfig lo:0 192.168.80.188 broadcast 192.168.80.188 netmask 255.255.255.255 uproute add-host 192.168.80.188 dev lo:0echo "1" > / proc/sys/net/ipv4/conf/lo/arp_ignoreecho "2" > / proc/sys/net/ipv4/conf/lo/arp_announceecho "1" > / proc/sys/net/ipv4/conf/all/arp_ignoreecho "2" > / proc/ Sys/net/ipv4/conf/all/arp_announcesysctl-p & > / dev/null:wqchmod + x web.sh./web.shifconfig

Scp web.sh root@192.168.80.101:/root / / transfer the web.sh file to the / root directory of the 192.168.80.101 virtual machine. Yes sets the password for root to write in 80.101. / web.shifconfig

Enter 192.168.80.188 on the web page

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