标签:lvs
LVS
etho: 172.16.6.61/16
eth0:172.16.6.100/16(VIP)
eth1: 192.168.6.61/24(DIP)
RS1
Centos 6.6eth0: 192.168.6.63/24
gw: 192.168.6.61/24LNMP
RS2
Centos 6.6
eth0: 192.168.6.64/24
gw: 192.168.6.61/24LNMP
DB
Centos 6.6
eth0: 192.168.6.65/24
lvs配置
#配置VIP地址
ifconfig eth0:0 172.16.6.100/32 broadcast 172.16.6.100 up
添加对vip的访问只能通过eth0:0
route add -host 172.16.6.100 dev eth0:0
打开系统路由转发功能
echo 1 > /proc/sys/net/ipv4/ip_forward
清空iptables规则
iptables -F
iptables -X
iptables -Z
安装ipvsadm
yum install -y ipvsadm
配置ipvs 规则
ipvsadm -A -t 172.16.6.100:80 -s rr
ipvsadm -a -t 172.16.6.100:80 -r 192.168.6.63 -m -w 1
ipvsadm -a -t 172.16.6.100:80 -r 192.168.6.64 -m -w 1
配置rs节点
配置lnmp
设置本机网关为192.168.6.61
route add default gw 192.168.6.61
客户机访问
[root@localhost ~]# curl http://172.16.6.100
web1
[root@localhost ~]# curl http://172.16.6.100
web2.com
[root@localhost ~]# curl http://172.16.6.100
web1
本文出自 “牧羊人” 博客,请务必保留此出处http://1066875821.blog.51cto.com/2375046/1655389
标签:lvs
原文地址:http://1066875821.blog.51cto.com/2375046/1655389