Three virtual machines to do LVS load balancing experiment, VM01 is load balancer, VM02 and vm03 are real Web servers, their relationship
Vm01
eth0:192.168.1.200
eth1:192.168.87.140 (where the 192.168.87.0 network segment can be connected to the extranet)
vip:192.168.87.30
Vm02
eth1:192.168.1.201 (gateway:192.168.1.200)
Vm03
eth1:192.168.1.202 (gateway:192.168.1.200)
First, Load balancer installation
Ipvs is the foundation of the entire load balancing, and without this foundation, fault isolation and failover are meaningless
[Root@vm01 ~]# Yum install-y ipvsadm
[Root@vm01 ~]# lsmod |grep Ip_vs
[Root@vm01 ~]# modprobe Ip_vs
[Root@vm01 ~]# lsmod |grep Ip_vs
Ip_vs 122241 0
It is not up to the process to judge if the Ip_vs module is loaded, because here is a command and no process is generated.
Second, create the Lvsnat mode startup script
Ipvsadm's Command reference:
-a--add-service adds a new virtual server record to the kernel's Virtual server table. Also
is to add a new virtual server.
-e--edit-service Edit a virtual server record in the Kernel Virtual server table.
-D--delete-service Deletes a virtual server record from the kernel Virtual server table.
-C--clear clears all records in the kernel Virtual server table.
-R--restore Restore virtual Server rules
-S--save save virtual Server rules, output to the-r option readable format
-a--add-server adds a new real server to a record in the Kernel Virtual server table
Recording. That is, adding a new real server to a virtual server
-e--edit-server edit a real server record in a virtual server record
-D--delete-server Deletes a real server record from a virtual server record
-l|-l--list display kernel Virtual server table
-Z--zero Virtual Service Table counter clear 0 (empty current number of connections, etc.)
--set TCP tcpfin UDP set Connection timeout value
--start-daemon initiates the synchronization daemon. He could be master or backup, for example.
Ming LVs Router is master or backup. You can also use keepalived in this function.
VRRP function.
--stop-daemon Stop the synchronization daemon
-H--help Display Help information
Other options:
-T--tcp-service service-address indicates that the virtual server provides TCP services
[Vip:port] or [Real-server-ip:port]
-U--udp-service service-address indicates that the virtual server provides UDP services
[Vip:port] or [Real-server-ip:port]
-F--fwmark-service fwmark description is a service type that has been iptables marked.
-S--scheduler Scheduler uses a scheduling algorithm that has several options
RR|WRR|LC|WLC|LBLC|LBLCR|DH|SH|SED|NQ,
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Servers/virtualization/