centos安装lvs

#安装
yum install ipvsadm -y
#设置超时时间
ipvsadm --set 30 5 60
#配置vip
ipvsadm -A -t 10.0.0.1:80 -s wrr -p 20
-A 添加服务端
-t tcp
-s 轮询算法
-p 会话吧保持时间
#添加客户端
ipvsadm -a -t 10.0.0.1:80 -r 10.0.0.2:80 -g -w 1
ipvsadm -a -t 10.0.0.1:80 -r 10.0.0.3:80 -g -w 1
-g 是dr模式
-w 权重
-a 指定客服端
#保存配置
ipvsadm-save -n >/tmp/lvs.bak
#重新配置文件
ipvsadm-restore -n </tmp/lvs.bak

#手动添加vip
#lb01
ip addr add 10.0.0.1/24 dev eth0 label eth0:1
#删除
ip addr del 10.0.0.1/24 dev eth0 label eth0:1

#web01 web02
#添加vip
ip addr add 10.0.0.1/32 dev lo label lo:1
#不让web上的vip解析
cat >>/etc/sysctl.conf<<EOF
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
EOF
sysctl -p

#查看访问了多少次
[root@test ~ 19:20:04]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.0.0.1:80 wrr persistent 20
-> 10.0.0.2:80 Route 1 1 0
-> 10.0.0.3:80 Route 1 0 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值