LVS-DR type
1. When the front-end route sends the request to the VIP, it can only be the VIP on the Director
solution
1.LVS-dirtory configuration binding static VIP address
2. Modify the kernel parameters of RS, configure the VIP on RS on the alias of the lo interface,
Characteristics of the LVS-DR type
1. RS can use private addresses or public addresses.
2. The gateway of RS must not point to DIP
3.RS and Dirctory should be in the same network
4. The client request is through the lvs-dictory, but the returned data is provided by the latter RS.
RS configuration
RS modifies the kernel and binds the VIP script
#! /bin/bash VIP=192.168.72.200 case "$1" in start) ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP /sbin/route add -host $VIP dev lo:0 echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce sysctl -p >/dev/null 2>&1 echo "RealServer Start OK" ;; stop) ifconfig lo:0 down route del $VIP >/dev/null 2>&1 echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped" ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0
LVS-Director server configuration
The server needs to be configured to bind vip
Install ipvsadm and configure
yum install ipvsadm -y
ipvsadm -A -t 192.168.72.200:80 -s rr
ipvsadm -a -t 192.168.72.200:80 -r 192.168.72.135 -g
ipvsadm -a -t 192.168.72.200:80 -r 192.168.72.136 -g
ipvsadm -L -n
A brief description of the parameters
-A: add a cluster service
-t:tcp
-u : udp
-f: firewall make is usually used when binding two or more services into one service for processing
service-address
-t IP:port
-u ip:port
-f firewall_mark
-s scheduling algorithm, default is wlc
-p: timeout persistent connection persistent connection
-E: Modify the defined cluster service
-D -t|u|f service-address: delete the specified cluster service
RS related
-a: add RS to the specified CS
-t|-u|-f service-address: Indicates which Cluster Service to add RS to
-r: Specify RS, which can include {IP[:port]}. Only LVS types that support port mapping are allowed to use ports different from those in the cluster service.
lvs type:
-g:Gateway,DR
-i : ipip, TUN
-m:masquerade (address masquerading), NAT
Default is DR
Specify RS Weights
-w
upper limit lower limit:
-x: lower limit
-y: upper limit
-e: Modify the specified RS attribute
-d -t|u|f service-address -r server-address: delete a specified RS in the specified cluster service
Case all cluster services:
-C
Save the rule (with output redirection):
ipvsadm-save
ipvaadm -S > file path
Load the specified rule: (using input redirection)
ipvsadmin-restore
ipvasdm -R < file path
View ipvs rules, etc.
-L [options]
-n Display the IP address in numeric format, no inversion
-c: View information about the number of connections
--stats: show statistics
--rate: data transfer rate
--timeout: show the duration of the tcp session
--daemon: information about the daemon
--sort: sort virtual services, default is ascending
--exact: accurate display, no unit conversion
-Z: the counter is cleared