服务器虚拟交换机到网卡不通,浅析虚拟化环境网卡绑定模式

作者:郭国华,新炬网络高级技术专家。

随着云计算的发展,虚拟化技术已普遍应用于各类型企业,同时虚拟化为服务器带来密集的网络吞吐压力已成为影响云计算发展的最大性能瓶颈之一,为了最大化提升主机网络性能,对不同的业务场景主机需配置合理的网卡BOND模式,本项目将在不对交换机做特别设置的KVM虚拟化环境下(交换机采用Trunk模式)对七种双网卡BOND模式进行测试,用数据说话浅析虚拟化环境网卡绑定模式应该如何选择。

一、测试环境方法介绍

(一)网络拓扑图

ecbab2873a3ad84e0a66d3cd6fa21cbd.png

(二)测试环境及工具:

本项目使用2台服务器(各跑一台虚拟机)、3台交换机KVM虚拟化环境进行测试,测试软硬件环境及工具如下:

1、 服务器:2台IBM X3950M2服务器(带2张千兆网卡),2台虚拟机;

2、 交换机:1台Cisco Nexus 5548P,2台Cisco Nexus 2248TP,Trunk模式;

3、 操作系统:linux redhat6.2,KVM虚拟化、网卡桥接模式(见上图);

4、 测试工具:netperf、ping、scp、sar、iostat。

(三)具体测试项

拟定BOND模式的测试项目如下:

1、 丢包率测试:通过ping命令测试主机间网络丢包情况;

2、 网卡切换效率测试:通过down、up网卡测试切换过程ping与文件传输的中断情况;

3、 网络TCP、UDP吞吐量:通过netperf命令分别测试TCP与UDP的吞吐量;

4、 网络速率测试:通过网络传输文件测试网络接收、发送速率。

二、七种网卡绑定模式介绍

网卡绑定7种模式官方说明如下,网上一堆资料在此不再赘述:

mode=0 (balance-rr)

Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.

mode=1 (active-backup)

Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.

mode=2 (balance-xor)

XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.

mode=3 (broadcast)

Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.

mode=4 (802.3ad)

IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

Pre-requisites: 1. Ethtool support in the base drivers for retrieving the speed and duplex of each slave. 2. A switch that supports IEEE 802.3ad Dynamic link aggregation. Most switches will require some type of configuration to enable 802.3ad mode.

mode=5 (balance-tlb)

Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.

Prerequisite: Ethtool support in the base drivers for retrieving the speed of each slave.

mode=6 (balance-alb)

Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.

三、测试结果

通过测试发现只有3种模式适用于该虚拟化环境的虚拟机通讯需求,详见下表:

a6ff1687d3d75e39d44d049793fc8a3d.png

四、关键问题分析

也许大家比较疑惑“mod=0,mod=3、mod=4”大多需要交换机支持在该环境不适用还算正常,但“mod=6”是常用的负载均衡模式为什么不适用呢?通过分析情况如下:

(一)mod=6虚拟机ping丢包大于90%

mod=6模式:交换机ACCESS模式物理机通讯正常,交换机trunk模式虚拟机能ping通网关,虚拟机之间互ping断断续续的能ping通几个包丢包率达90%,原因:N5K学习到虚拟机的MAC地址不对(为物理机MAC地址),故虚拟机之间ping不通;路由端学习到虚拟机的MAC地址正确故虚拟机ping网关正常。

(二)mod=6另一个需要关注问题

mod=6,该模式有一个需要特别关注的问题,当一个网卡状态不稳定(时down时up)的时候,网络切换平衡过程将会频繁进入混杂模式导致网络不通,临时解决办法为down掉异常的网卡,在运维过程中应该加强网卡状态的监控。注:网卡损坏的情况下可正常切换不影响网络通讯。

五、模式选择建议

通过对测试结果的总结分析发现,仅有3种模式(mod=1,mod=2,mod=5)适用于KVM虚拟化多网络隔离的模式(交换机Trunk模式),3种模式的优缺点如下:

(一)mod=1

即: (active-backup) Active-backup policy(主-备份策略)

特点:只有一个设备处于活动状态,当一个宕掉另一个马上由备份转换为主设备;此模式只提供了容错能力,ping无丢包,网卡切换过程ping无中断、文件传输无中断;文件传输过程网络接收、发送速率均处于较稳定状态(约100MB/S),整个测试过程主机网络均处于较稳定的状态,业界大多虚拟化环境采用该模式稳定及高可用性已得到了充分的证明。

(二)mod=2

即:(balance-xor) XOR policy(平衡策略)

特点:基于指定的传输HASH策略传输数据包;此模式提供负载平衡和容错能力,ping无丢包(丢失会重复ping);网卡切换过程ping中断1-2秒(网卡重新up过程ping不稳定)、文件传输无中断,文件传输过程网络接收、发送速率提升约90%(约190MB/S)。另:因采用本机地址与目的地址XOR决定传输路径,通过网关(每次XOR的地址一样)的传输固定在一条路径,故跨网段未能实现负载平衡。网上众多资料显示该模式需要交换机支持(端口配置“port channel”),实际测试并非如此,故技术是实践出来的使用前做好详细测试不要盲从。

(三)mod=5,

即:(balance-tlb) Adaptive transmit load balancing(适配器传输负载均衡)

特点:不需要任何特别的switch(交换机)支持的通道bonding。在每个slave上根据当前的负载(根据速度计算)分配外出流量。此模式提供外出流量负载平衡与容错能力,ping无丢包;网卡切换过程ping无中断(同模式间up网卡时ping断约5秒)、文件传输无中断;文件传输过程网络接收速率未实现负载平衡(约110MB/S)、网络发送速率实现负载平衡约提升50%(约160MB/S)。该模式与前面2种比较稳定性稍差,且只提供了单向负载均衡同时速率提升不明显,不建议使用。

选择建议:

mod=1模式的稳定性、高可用性已久经考验,如无特殊需求则是虚拟化环境网卡模式的首选;如对虚拟机之间的传输带宽有较大的需求,可对mod=2的模式进行详细测试后选择使用;如前2种模式均无法满足需求再考虑通过修改交换机配置选择其它的模式,因为云计算的网络环境通常比较复杂,牵一发而动全身请慎重使用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值