Linux下负载均衡软件LVS配置(VS/DR)教程
发布:smiling 来源: PHP粉丝网 添加日期:2015-04-21 15:02:42 浏览: 评论:0
LVS负载均衡有很多的方式今天,本文章介绍的是负载均衡VS/DR模式了,对于这个模式下面小编会简单的给各位介绍一下,有兴趣的可进来看看.
VS/DR:即(Virtual Server via Direct Routing)
也就是用直接路由技术实现虚拟服务器,它的连接调度和管理与VS/NAT和VS/TUN中的一样,但它的报文转发方法又有不同,VS/DR通过改写请求报文的MAC地址,将请求发送到Real Server,而Real Server将响应直接返回给客户,免去了VS/TUN中的IP隧道开销,这种方式是三种负载调度机制中性能最高最好的,但是必须要求Director Server与Real Server都有一块网卡连在同一物理网段上.
例子:
- DIP:172.28.95.220
- VIP:172.28.95.245
- RIP:172.28.95.221(222)
负载调度器:
- [root@LVS-GS001 ipvsadm-1.24]# ifconfig eth1:1 172.28.95.245 netmask 255.255.255.0 up
- [root@LVS-GS001 ipvsadm-1.24]# ifconfig
- eth1 Link encap:Ethernet HWaddr 00:15:5D:C7:83:7D
- inet addr:172.28.95.220 Bcast:172.28.95.255 Mask:255.255.240.0
- eth1:1 Link encap:Ethernet HWaddr 00:15:5D:C7:83:7D
- inet addr:172.28.95.245 Bcast:172.28.95.255 Mask:255.255.255.0
- UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
- Interrupt:9 Base address:0xc000
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm
- IP Virtual Server version 1.2.1 (size=4096)
- Prot LocalAddress:Port Scheduler Flags
- -> RemoteAddress:Port Forward Weight ActiveConn InActConn
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm --help
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm --set 30 5 60 #--set tcp tcpfin udp set connection timeout values
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm -A -t 172.28.95.245:80 -s wrr -p 20 #-A add virtual service with options #-s scheduler one of rr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,the default scheduler is wlc.
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm -L -n
- IP Virtual Server version 1.2.1 (size=4096)
- Prot LocalAddress:Port Scheduler Flags
- -> RemoteAddress:Port Forward Weight ActiveConn InActConn
- TCP 172.28.95.245:80 wrr persistent 20
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm -a -t 172.28.95.245:80 -r 172.28.95.221:80 -g -w 1
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm -a -t 172.28.95.245:80 -r 172.28.95.222:80 -g -w 1
- [root@LVS-GS001 ipvsadm-1.24]# ipvsadm -L -n
- IP Virtual Server version 1.2.1 (size=4096)
- Prot LocalAddress:Port Scheduler Flags
- -> RemoteAddress:Port Forward Weight ActiveConn InActConn
- TCP 172.28.95.245:80 wrr persistent 20
- -> 172.28.95.222:80 Route 1 0 0
- -> 172.28.95.221:80 Route 1 0 0
- Real-Server:
- [root@RealServer001 ~]# ifconfig lo:221 172.28.95.245:80 netmask 255.255.255.255 up
- [root@RealServer001 ~]# echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore --phpfensi.com
- [root@RealServer001 ~]# echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
- [root@RealServer001 ~]# echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
- [root@RealServer001 ~]# echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
Tags: Linux负载均衡 LVS配置
推荐文章
热门文章
最新评论文章
- 写给考虑创业的年轻程序员(10)
- PHP新手上路(一)(7)
- 惹恼程序员的十件事(5)
- PHP邮件发送例子,已测试成功(5)
- 致初学者:PHP比ASP优秀的七个理由(4)
- PHP会被淘汰吗?(4)
- PHP新手上路(四)(4)
- 如何去学习PHP?(2)
- 简单入门级php分页代码(2)
- php中邮箱email 电话等格式的验证(2)