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-GS001ipvsadm-1.24]#ifconfigeth1:1172.28.95.245netmask255.255.255.0up
- [root@LVS-GS001ipvsadm-1.24]#ifconfig
- eth1Linkencap:EthernetHWaddr00:15:5D:C7:83:7D
- inetaddr:172.28.95.220Bcast:172.28.95.255Mask:255.255.240.0
- eth1:1Linkencap:EthernetHWaddr00:15:5D:C7:83:7D
- inetaddr:172.28.95.245Bcast:172.28.95.255Mask:255.255.255.0
- UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
- Interrupt:9Baseaddress:0xc000
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm
- IPVirtualServerversion1.2.1(size=4096)
- ProtLocalAddress:PortSchedulerFlags
- ->RemoteAddress:PortForwardWeightActiveConnInActConn
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm--help
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm--set30560#--settcptcpfinudpsetconnectiontimeoutvalues
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm-A-t172.28.95.245:80-swrr-p20#-Aaddvirtualservicewithoptions#-sscheduleroneofrr|wrr|lc|wlc|lblc|lblcr|dh|sh|sed|nq,thedefaultscheduleriswlc.
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm-L-n
- IPVirtualServerversion1.2.1(size=4096)
- ProtLocalAddress:PortSchedulerFlags
- ->RemoteAddress:PortForwardWeightActiveConnInActConn
- TCP172.28.95.245:80wrrpersistent20
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm-a-t172.28.95.245:80-r172.28.95.221:80-g-w1
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm-a-t172.28.95.245:80-r172.28.95.222:80-g-w1
- [root@LVS-GS001ipvsadm-1.24]#ipvsadm-L-n
- IPVirtualServerversion1.2.1(size=4096)
- ProtLocalAddress:PortSchedulerFlags
- ->RemoteAddress:PortForwardWeightActiveConnInActConn
- TCP172.28.95.245:80wrrpersistent20
- ->172.28.95.222:80Route100
- ->172.28.95.221:80Route100
- Real-Server:
- [root@RealServer001~]#ifconfiglo:221172.28.95.245:80netmask255.255.255.255up
- [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