标签:grep client hostname index har 3.2 3.1 tab 节点
一、环境介绍
1)RIP、VIP、DIP为同一物理网络
2)LVS
Hostname:lvs
eth0:DIP-192.168.3.31
eth0:0:VIP-192.168.3.10
3)RS1
Hostname:web1
eth0:RIP-192.168.3.32
lo:0:VIP-192.168.3.10
4)RS2
Hostname:web2
eth0:RIP-192.168.3.33
lo:0:VIP-192.168.3.10
5)Client
Hostname:user
eth0:CIP-192.168.3.25
6)所有主机均使用Centos7
二、安装配置
1、清空节点防火墙规则
[root@lvs ~]# for i in filter nat mangle;do iptables -t $i -F && iptables -t $i -X && iptables -t $i -Z;done
[root@web1 ~]# for i in filter nat mangle;do iptables -t $i -F && iptables -t $i -X && iptables -t $i -Z;done
[root@web2 ~]# for i in filter nat mangle;do iptables -t $i -F && iptables -t $i -X && iptables -t $i -Z;done
[root@user ~]# for i in filter nat mangle;do iptables -t $i -F && iptables -t $i -X && iptables -t $i -Z;done
# 生产环境,防火墙规则根据实际情况进行配置
2、配置LVS-VIP
[root@lvs ~]# ifconfig eth0:0 192.168.3.10/32 broadcast 192.168.3.10 up # 注意子网掩码为32位;【broadcast 192.168.3.10】为可选配置,用以实现仅广播给自己
[root@lvs ~]# route add -host 192.168.3.10 dev eth0:0 # 此选项为可选配置,而RS必须如此配置
[root@lvs ~]# ifconfig eth0:0
略
[root@web1 ~]# ping -c 1 192.168.3.10 &>/dev/null && echo ok || echo false
ok
[root@web2 ~]# ping -c 1 192.168.3.10 &>/dev/null && echo ok || echo false
ok
3、配置RS-VIP
[root@web1 ~]# echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
[root@web1 ~]# echo "1" >/proc/sys/net/ipv4/conf/eth0/arp_ignore # 仅配置all即可,但为确保万无一失,同时为eth0进行配置
[root@web1 ~]# echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
[root@web1 ~]# echo "2" >/proc/sys/net/ipv4/conf/eth0/arp_announce
[root@web1 ~]# ifconfig lo:0 192.168.3.10/32 broadcast 192.168.3.10 up # 注意子网掩码为32位;【broadcast 192.168.3.10】用以实现仅广播给自己
[root@web1 ~]# route add -host 192.168.3.10 dev lo:0 # 确保必须由lo:0接口发送响应报文,以实现响应报文的源IP地址为VIP
[root@web2 ~]# echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
[root@web2 ~]# echo "1" >/proc/sys/net/ipv4/conf/eth0/arp_ignore
[root@web2 ~]# echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
[root@web2 ~]# echo "2" >/proc/sys/net/ipv4/conf/eth0/arp_announce
[root@web1 ~]# ifconfig lo:0 192.168.3.10/32 broadcast 192.168.3.10 up
[root@web1 ~]# route add -host 192.168.3.10 dev lo:0
[root@user ~]# ping -c 1 192.168.3.10 &>/dev/null && echo ok || echo false
ok
[root@user ~]# arp -a|grep 192.168.3.10|egrep -o "..:..:..:..:..:.."
00:0c:29:b2:e4:ec
[root@lvs ~]# ifconfig eth0:0|egrep -o "..:..:..:..:..:.."
00:0c:29:b2:e4:ec
4、配置RS-WEB
[root@web1 ~]# yum install -y nginx && echo "$HOSTNAME" > /usr/share/nginx/html/index.html && nginx && curl 127.0.0.1
web1
[root@web2 ~]# yum install -y nginx && echo "$HOSTNAME" > /usr/share/nginx/html/index.html && nginx && curl 127.0.0.1
web2
[root@lvs ~]# curl 192.168.3.32 192.168.3.33
web1
web2
5、配置LVS-IPVS
[root@lvs ~]# yum install -y ipvsadm
[root@lvs ~]# ipvsadm -A -t 192.168.3.10:80 -s rr
[root@lvs ~]# ipvsadm -a -t 192.168.3.10:80 -r 192.168.3.32 -g
[root@lvs ~]# ipvsadm -a -t 192.168.3.10:80 -r 192.168.3.33 -g
[root@user ~]# for i in {1..4};do curl 192.168.3.10;done
web1
web2
web1
web2
一、环境介绍
1)RIP、DIP为同一物理网络,VIP不与RIP、DIP在同一物理网络
2)LVS
Hostname:lvs
eth0:DIP-192.168.30.129
eth0:0:VIP-192.168.3.10
3)RS1
Hostname:web1
eth0:RIP-192.168.30.137
lo:0:VIP-192.168.3.10
4)RS2
Hostname:web2
eth0:RIP-192.168.30.131
lo:0:VIP-192.168.3.10
5)Client
Hostname:user
eth0:CIP-192.168.3.25
6)Route
Hostname:route
eth0:192.168.3.34
eth1:192.168.30.138
7)所有主机均使用Centos7
二、安装配置
略
标签:grep client hostname index har 3.2 3.1 tab 节点
原文地址:https://www.cnblogs.com/liming-linux-python/p/10421113.html