ipvsadm iptables 的区别和联系
lvs DR 的工作方式就是MAC
注意:lvs nat模式 vip和dip不能在同一网段(一定要两块网卡)
lvs:隧道模式的实现:
调度机:
echo 1 > /proc/sys/net/ipv4/ip_forward
net.ipv4.ip_forward = 1
sysctl -p
配置lvs隧道模式:
ipvsadm -C(清除之前的规则)
ipvsadm -A -t 172.25.24.200:80 -s rr
ipvsadm -a -t 172.25.24.200:80 -r 172.25.24.7:80 -i(-i 隧道模式)
ipvsadm -a -t 172.25.24.200:80 -r 172.25.24.8:80 -i
modprobe ipip(在加载好ipip模块后就会有默认的tunl0隧道)
ifconfig -a #查看
ip addr add 172.25.24.200/24 dev tunl0
ip link set up tunl0
RealServer:(两台)
ARP访问控制:
arptables -A IN -d 172.25.24.200 -j DROP
arptables -A OUT -s 172.25.24.200 -j mangle --mangle-ip-s 172.25.24.7
modprobe ipip(在加载好ipip模块后就会有默认的tunl0隧道)
ifconfig -a #查看
ip addr add 172.25.24.200/24 dev tunl0
88 ip link set up tunl0
sysctl -a | grep rp_filter
sysctl -w net.ipv4.conf.default.rp_filter = 0
sysctl -w net.ipv4.conf.default.rp_filter=0
sysctl -a | grep rp_filter
sysctl -w net.ipv4.conf.lo.rp_filter=0
sysctl -a | grep rp_filter
sysctl -w net.ipv4.conf.eth1.rp_filter=0
sysctl -a | grep rp_filter
sysctl -w net.ipv4.conf.eth0.rp_filter=0
sysctl -a | grep rp_filter
sysctl -w net.ipv4.conf.tunl0.rp_filter=0
sysctl -a | grep rp_filter
sysctl -p 永久生效
后端的rs做好httpd
真实物理机测试:curl vip
tar zxvf webbench-1.5.tar.gz
cd webbench-1.5
make
mkdir -p /usr/local/man/man1 #不创建这个执行make install会报错
make install
进行压力测试
webbench -h
参数: -c为客户端数,-t为时间(秒)
当为1个客户端时,持续访问1秒
webbench -c 1 -t 1 http://vip/index.html
使用20个客户端并发访问并持续访问10秒
webbench -c 20 -t 10 http://vip/index.html
当并发为800时持续时间60秒
webbench -c 800 -t 60 http://192.168.1.63/index.html
监控调度机:
vmstat 1 20
vmstat命令是最常见的Linux/Unix监控工具,可以展现给定时间间隔的服务器的状态值,包括服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况
一般vmstat工具的使用是通过两个数字参数来完成的,第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数