这里添加健康检查是三层转发的要求,真实服务器端口是多少,这里写多少
/c/slb/advhc/health tcp80 TCP/dport 80
/c/slb/real RS_test/ena
/c/slb/real RS_test/ipver v4
/c/slb/real RS_test/rip 192.168.47.154
/c/slb/real RS_test/maxcon 0 logical #设置逻辑连接数不限制
/c/slb/real RS_test/name "RS_test"
/c/slb/group RS_Group_test/ipver v4
/c/slb/group RS_Group_test/health tcp80 #这里选择健康检查方式
/c/slb/group RS_Group_test/metric roundrobin #这里选择负载均衡算法
/c/slb/group RS_Group_test/add RS_test #这里向这个组添加RS
/c/slb/group RS_Group_test/name "RS_Group_test"
/c/slb/virt vip_test/ena
/c/slb/virt vip_test/ipver v4
/c/slb/virt vip_test/vip 192.168.47.146
/c/slb/virt vip_test/layr3 ena #开启三层转发
/c/slb/virt vip_test/service 1 ip/group RS_Group_test
/c/slb/virt vip_test/service 1 ip/rport 1
/c/slb/virt vip_test/service 1 ip/nonat ena #设置nat不转换
/c/slb/virt vip_test/service 1 ip/direct dis
cat << EOF > /etc/sysctl.conf
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
EOF
sysctl -p /etc/sysctl.conf #加载内核配置
arp_ignore参数的值及其含义如下:
0 - (默认值): 回应任何网络接口(网卡)上对任何本机IP地址的arp查询请求。比如eth0=192.168.0.1/24,eth1=10.1.1.1/24,那么即使eth0收到来自10.1.1.2这样地址发起的对10.1.1.1 的arp查询也会给出正确的回应;而原本这个请求该是出现在eth1上,也该有eth1回应的。
1 - 只回答目标IP地址是本机上来访网络接口(网卡)IP地址的ARP查询请求 。比如eth0=192.168.0.1/24,eth1=10.1.1.1/24,那么即使eth0收到来自10.1.1.2这样地址发起的对192.168.0.1的查询会回应,而对10.1.1.1 的arp查询不会回应。
2 -只回答目标IP地址是本机上来访网络接口(网卡)IP地址的ARP查询请求,且来访IP(源IP)必须与该网络接口(网卡)上的IP(目标IP)在同一子网段内 。比如eth0=192.168.0.1/24,eth1=10.1.1.1/24,eth1收到来自10.1.1.2这样地址发起的对192.168.0.1的查询不会回应,而对192.168.0.2发起的对192.168.0.1的arp查询会回应。
3 - do not reply for local addresses configured with scope host,only resolutions for global and link addresses are replied。(不知道怎么翻译合适,网上有一个参考但我认为无法理解它的含义:不回应该网络界接口的arp请求,而只对设置的唯一和连接地址做出回应)
4-7 - 保留未使用
8 -不回应所有(本机地址)的arp查询
[root@154 ~]# cat /etc/sysconfig/network-scripts/ifcfg-lo:1
DEVICE=lo:1
IPADDR=这里是上面配置的vip
NETMASK=255.255.255.255
NETWORK=192.168.47.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=192.168.47.255
ONBOOT=yes
NAME=loopback1
[root@154 ~]# systemctl restart network
/c/slb/real 47_153_80/ena
/c/slb/real 47_153_80/ipver v4
/c/slb/real 47_153_80/rip 192.168.47.153
/c/slb/real 47_153_80/maxcon 0 logical
/c/slb/real 47_153_80/addport 80
/c/slb/group Groups/ipver v4
/c/slb/group Groups/add 47_153_80
/c/slb/group Groups/name "Groups"
/c/slb/virt vip_test/ena
/c/slb/virt vip_test/ipver v4
/c/slb/virt vip_test/vip 192.168.47.146
/c/slb/virt vip_test/rtsrcmac ena
/c/slb/virt vip_test/service 80 http/group Groups
/c/slb/virt vip_test/service 80 http/rport 0
/c/slb/virt vip_test/service 80 http/pip/mode address
/c/slb/virt vip_test/service 80 http/pip/addr v4 192.168.47.146 255.255.255.255 persist disable
这个模式服务器不需要做什么复杂的配置,正常起服务就可以了。