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

Overview and Construction of load balancing Cluster based on Direct routing pattern (DR)

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

Share

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

The following gives you an overview of load balancing cluster based on direct routing pattern (DR) and its construction, hoping to give you some help in practical application. Load balancing involves many things, 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.

First, start configuring DR mode LVS

Preparatory work:

Four Centos 7 operating systems

Centos01 simulated Web1 CVM: IP address / 192.168.100.10

Centos02 Analog Web2 Server: IP address / 192.168.100.20

Centos03 Analog NFS Server: IP address / 192.168.100.30

Centos05 Analog LVS Server: IP address / 192.168.100.50

One Windows client

1. Configure the load scheduler

1) configure virtual IP address (VIP) [root@centos05 ~] # cp / etc/sysconfig/network-scripts/ifcfg-ens32 / etc/sysconfig/network-scripts/ifcfg-ens32:0 [root@centos05 ~] # vim / etc/sysconfig/network-scripts/ifcfg-ens32:0 TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=staticDEFROUTE=yesNAME=ens32:0 DEVICE=ens32:0 ONBOOT=yesIPADDR=192.168.100.253 NATEMASK=255.255.255.0 [root@centos05 ~] ] # systemctl restart network [root@centos05 ~] # ifconfig ens32: flags=4163 mtu 1500 inet 192.168.100.50 netmask 255.255.255.0 broadcast 192.168.100.255 inet6 fe80::20c:29ff:fe16:c54b prefixlen 64 scopeid 0x20 ether 00:0c:29:16:c5:4b txqueuelen 1000 (Ethernet) RX packets 2795 bytes 1095013 (1.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1371 bytes 182001 (177.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens32:0: flags=4163 mtu 1500 inet 192.168.100.253 netmask 255.255.255.0 broadcast 192.168.100.255 ether 00:0c:29:16:c5:4b txqueuelen 1000 (Ethernet) 2) adjust / proc corresponding parameter [root@centos05 ~] # vim / etc/sysctl.conf net.ipv4.ip_forward = 1net.ipv4.conf.all.send_redirects = 0net.ipv4.conf.default.send_redirects = 0net.ipv4.conf.ens32.send_redirects = 0 [root@centos05 ~] # sysctl-p 3) configure load distribution policy [root@centos05 ~] # modprobe ip_vs [root@centos05 ~] # yum-y install ipvsadm [root@centos05 ~] # ipvsadm-C [root@centos05 ~] # ipvsadm-A-t 192.168.100.253ju80 -s rr [root@centos05 ~] # ipvsadm-a-t 192.168.100.253 ipvsadm 80-r 192.168.100.10 ipvsadm 80-g-w 1 [root@centos05 ~] # ipvsadm-a-t 192.168.100.253 ipvsadm 80-r 192.168.100.20 root@centos05 80-g-w 1 [root@centos05 ~] # ipvsadm-save > / etc/sysconfig/ipvsadm [root@centos04 ~] # ipvsadm- ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags-> RemoteAddress:Port Forward Weight ActiveConn InActConnTCP 192.168.100.253 Route 80 rr-> 192.168.100.10 root@centos04 80 Route 100 -> 192.168.100.20 Route 80 1002, Configure web Node 1 Server [root@centos01 ~] # yum-y install httpd [root@centos01 ~] # echo "www.benet.com" > / var/www/html/index.html [root@centos01 ~] # systemctl start httpd [root@centos01 ~] # systemctl enable httpd [root@centos01 ~] # cp / etc/sysconfig/network-scripts/ifcfg-lo / etc/sysconfig / network-scripts/ifcfg-lo:0 [root@centos01 ~] # vim / etc/sysconfig/network-scripts/ifcfg-lo:0 DEVICE=lo:0IPADDR=192.168.100.253NETMASK=255.255.255.255ONBOOT=yes [root@centos01 ~] # systemctl restart network [root@centos01 ~] # ifconfig lo:0: flags=73 mtu 65536 inet 192.168.100.253 netmask 255.255.255.255 loop txqueuelen 1 (Local Loopback) [root@centos01 ~] # vim / etc/sysctl.conf net.ipv4.conf.all.arp_ignore = 1net.ipv4.conf.all.arp_announce = 2net.ipv4.conf.default.arp_ignore = 1net.ipv4.conf.default.arp_announce = 2net.ipv4.conf.lo.arp_ignore = 1net.ipv4.conf.lo.arp_announce = 2 [root@centos01 ~] # sysctl-p 3, Configure web Node 2 server [root@centos02 ~] # yum-y install httpd [root@centos02 ~] # echo "www.accp.com" > / var/www/html/index.html [root@centos02 ~] # systemctl start httpd [root@centos02 ~] # systemctl enable httpd [root@centos01 ~] # scp / etc/sysctl.conf root@192.168.100.20: / etc/ The authenticity of host '192.168.100.30 (192.168.100.20)' can't be established.ECDSA key fingerprint is SHA256:PUueT9fU9QbsyNB5NC5hbSXzaWxxQavBxXmfoknXl4I.ECDSA key fingerprint is MD5:6d:f7:95:0e:51:1a:d8:9e:7b:b6:3f:58:51:51:4b:3b.Are you sure you want to continue connecting (yes/no)? YesWarning: Permanently added '192.168.100.20' (ECDSA) to the list of known hosts.root@192.168.100.20's password: sysctl.conf [root@centos01 ~] # scp / etc/sysconfig/network-scripts/ifcfg-lo:0 root@192.168.100.20:/etc/sysconfig/network-scripts/root@192.168.100.20's password: ifcfg-lo:0 70 177.3KB/s 00:00 [root@centos02 ~] # sysctl-p net.ipv4.conf.all.arp_ignore = 1net.ipv4.conf.all.arp_announce = 2net.ipv4.conf.default.arp_ignore = 1net.ipv4.conf.default.arp_announce = 2net.ipv4.conf.lo.arp_ignore = 1net.ipv4.conf.lo.arp_announce = 2 [root@centos02 ~] # systemctl restart network 4, Client access

The client configuration and the server have the same network segment IP address, and the browser accesses http://192.168.100.253

If you close the browser and delete the cache, you will get a new page and load balancing will be realized.

Second, install NFS shared storage 1. Configure NFS [root@centos03 ~] # yum-y install rpcbind nfs-utils [root@centos03 ~] # mkdir / web [root@centos03 ~] # echo "www.nfs.com" > / web/index.html [root@centos03 ~] # vim / etc/exports / web 192.168.100.10 (ro) 192.168.100.20 (rw) [root@centos03 ~] # systemctl start rpcbind [root@centos03 ~] # systemctl start nfs [root@centos03 ~] # Systemctl enable rpcbind [root@centos03 ~] # systemctl enable nfs [root@centos03 ~] # showmount-e 192.168.100.30 Export list for 192.168.100.30:/web 192.168.100.20192.168.100.102, Web Node 1 server mounts the shared directory [root@centos01 ~] # mount 192.168.100.30:/web / var/www/html/ [root@centos01 ~] # cat / var/www/html/index.html www.nfs.com [root@centos01 ~] # systemctl restart httpd 3, Web Node 2 Server mounts a shared directory [root@centos02 ~] # mount 192.168.100.30:/web / var/www/html/ [root@centos02 ~] # cat / var/www/html/index.html www.nfs.com [root@centos02 ~] # systemctl restart httpd 4, client access

Use tail-f / var/log/httpd/access.log to view the access success log. Be sure to monitor and then access before you can see the effect.

5. Configure auto-mount NFS1) web node 1 server [root@centos01 ~] # vim / etc/fstab192.168.100.30:/web / var/www/html/ nsf defaults 0 02) web node 2 server [root@centos02 ~] # vim / etc/fstab192.168.100.30:/web / var/www/html/ nsf defaults 00

After reading the above overview and construction of load balancing cluster based on Direct routing pattern (DR), if there is anything else you need to know, you can find 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