标签:linux
ipvsadm nat模式配置
echo "1" >/proc/sys/net/ipv4/ip_forward
清空配置
ipvsadm -C
添加规则
ipvsadm -A -t 192.168.10.135:80 -s rr
ipvsadm -a -t 192.168.10.135:80 -r 172.16.6.12:80 -m
ipvsadm -a -t 192.168.10.135:80 -r 172.16.6.13:80 -m
查看配置
ipvsadm -L -n
保存配置
ipvsadm -S > /etc/sysconfig/ipvsadm
修改调度算法;
ipvsadm -E -t 192.168.10.135:80 -s sh
从保存的配置文件中重读配置
ipvsadm -C
ipvsadm -R < /etc/sysconfig/ipvsadm
ipvsadm -L -n
删除
ipvsadm -D -t 192.168.10.135:80
ipvsadm dr模型配置
(1)、LVS-server配置
a. VIP设置:
eth0:ip 192.168.0.101
ifconfig eth0:0 192.168.0.100 netmask 255.255.255.255
route add -host 192.168.0.100 dev eth0:0
b.安装Ipvsadm
yum -y install ipvsadm*
c.lvs配置:
ipvsadm -C
ipvsadm -At 192.168.0.100:80 -s rr
ipvsadm -at 192.168.0.100:80 -r 192.168.0.102:80 -g
ipvsadm -at 192.168.0.100:80 -r 192.168.0.103:80 -g
ipvsadm -L -n
(2)、Real-Server1配置
eth0:ip 192.168.0.102
ifconfig lo:0 192.168.0.100 netmask 255.255.255.255
route add -host 192.168.0.100 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
(3)、Real-Server2配置
eth0:ip 192.168.0.103
ifconfig lo:0 192.168.0.100 netmask 255.255.255.255
route add -host 192.168.0.100 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
标签:linux
原文地址:http://perper.blog.51cto.com/6284626/1972829