In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The following brings you LVS virtual cloud servers, load scheduling algorithms and others, hoping to give you some help in practical application. There are many things involved in load balancing, 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 virtual cloud server
Linux Virtual Server (LVS) is a load balancing project developed for the Linux kernel by our country
The official site is located at http://www.linuxvirtualserver.org/..
LVS is actually equivalent to a virtualized application based on IP address, which provides an efficient solution for load balancing based on IP address and content request distribution.
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.
Load scheduling algorithm of LVS
According to the needs of different network services and configurations, LVS scheduler provides a variety of different load scheduling algorithms, of which the four most commonly used algorithms include polling, weighted polling, minimum connection and weighted least connection.
Polling (RoundRobin): allocates received access requests sequentially to each section in the cluster
Point (real server).
Weighted polling (WeightedRoundRobin): the received access requests are allocated in turn according to the processing capacity of the real server. The scheduler can automatically query the load of each node and dynamically adjust its weight. This ensures that servers with strong processing power bear more access traffic.
Minimum connections (LeastConnections): based on the number of connections established by the real server, the received access requests are given priority to the node with the least number of connections.
Weighted least connection (WeightedLeastConnections): in the case of large differences in the performance of server nodes, the weight can be automatically adjusted for real servers, and the nodes with higher weights will bear a larger proportion of the active connection load.
Use ipvsadm management tools
Ipvsadm is a LVS cluster management tool used on the load scheduler to add and remove server nodes and view the operational status of the cluster by calling the ip_vs module. On Centos6 systems, you need to install the ipvsadm package manually. You can install it directly in centos7.
Address translation mode
Address translation (NetworkAddressTranslation) is referred to as NAT mode, which is similar to the private network structure of the firewall. The load scheduler acts as the gateway of all server nodes, that is, as the access entrance of the client and the access exit of each node responding to the client. The server node uses a private IP address, which is on the same physical network as the load scheduler, and its security is better than the other two ways.
Graphic illustration
Note: the node server acts on the private network, while the client acts on the public network. At this time, LVS acts as a gateway. When the node server feedback information to the client, it will go through LVS.
Experimental environment role IPLVS192.168.100.1 / 12.0.0.1apache1192.168.100.110apache2192.168.100.120NFS192.168.100.130 step to build httpd service on two node servers # yum install httpd-y # systemctl stop firewalld.service# setenforce 0 build NFS service installation service on NFS server # rpm-Q nfs-utils# rpm-Q rpcbind / / see if it is installed The service has installed and edited the configuration file # vim / etc/exports/usr/share * (ro,sync) / opt/benet 192.168.100.0 benet,192.168.100.0 24 (rw,sync) / / create directory benet,192.168.100.0 network segment can read, write and synchronize / opt/accp 192.168.100.0 Universe 24 (rw,sync) / / create directory accp 192.168.100.0 network segment can read, write and synchronize operations to create directories and grant permissions # mkdir / opt/benet / opt/accp# chmod 777 / opt/benet / opt/accp to start the nfs service and publish shares # systemctl start nfs.service# exportfs-rv / / publish shares
Node server mounts the shared file of the nfs server apache1 mounts / opt/benet to the site directory # showmount-e 192.168.100.130 / View the shared file # mount.nfs 192.168.100.130:/opt/benet / var/www/html/ / mount # cd / var/www/html/# echo "this is benet" > index.html# systemctl start httpd.service
Apache2 mounts / opt/accp to the site directory # showmount-e 192.168.100.130 / View the shared file # mount.nfs 192.168.100.130:/opt/accp / var/www/html / / Mount # echo "this is accp" > index.html# systemctl start httpd.service
LVS server (note dual network card) install ipvsadm management tool # yum install ipvsadm-y load kernel module # modprobe ip_vs set route forwarding (because it is dual network card) # vim / etc/sysctl.conf add: net.ipv4.ip_forward = immediate sysctl-p / / take effect immediately
Firewall set iptables-F# iptables-t nat-F# iptables-L iptables / clear all rules # iptables-t nat-I POSTROUTING-s 192.168.100.0 SNAT 24-o ens36-j SNAT-- to-source 12.0.0.1 / / set SNAT forwarding, convert all 192.168.100.0 segments to 12.0.0.1, and then access client
Turn on ipvsadm# systemctl start ipvsadm.service Note: there may be problems when opening the ipvsadm-- save > / etc/sysconfig/ipvsadm / / enter the line
Write an executable script # cd / opt# vi net.shanglang binipple Vsadm-Cipvsadm-A-t 12.0.0.1 Cipvsadm 80-s rripvsadm-a-t 12.0.0.1 Cipvsadm 80-r 192.168.100.110 mipvsadm 80-mipvsadm-a-t 12.0.0.1 mipvsadm 80-r 192.168.100.12080-mipvsadm# chmod + x net.sh#. / net.sh is explained as follows: ipvsadm-C / clear the kernel All records in virtual server table / /-A: add virtual server-s: specify scheduling algorithm rr: polling algorithm-a: add real server-t: specify public network gateway and TCP port-r: specify node server address and TCP port-m: use NAT cluster mode
Open a win7 for testing
Note: when you visit 12.0.0.1 two times in a row, you may not be able to switch for a while, and the original interface is still displayed. At this time, you must clear the cache in order to see two different interfaces. Of course, if you turn off the httpd service of one of the node servers at this time, when you visit 12.0.0.1, the other server's web interface will be displayed.
After reading the above about LVS virtual cloud servers, load scheduling algorithms and so on, 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.