Linux网卡绑定实现带宽翻倍

之前有过一篇BLOG,是介绍如何简单的将Linux两张网卡进行绑定,已实现高可用。但在之前的模式里,仅仅能实现高可用,当两个网卡中的一个失效时并不会影响服务器的联通性。

但是,如果有交换机的配合,是否可以时间负载均衡,同时达到带宽翻倍的目的呢?

首先,需要先明确,绑定的各种模式

0 - Sets a round-robin policy for fault tolerance and load balancing. Transmissions are received and sent out sequentially on each bonded slave interface beginning with the first one available.

1 - Sets an active-backup policy for fault tolerance. Transmissions are received and sent out via the first available bonded slave interface. Another bonded slave interface is only used if the active bonded slave interface fails.

2 - Sets an XOR (exclusive-or) policy for fault tolerance and load balancing. Using this method, the interface matches up the incoming request's MAC address with the MAC address for one of the slave NICs. Once this link is established, transmissions are sent out sequentially beginning with the first available interface.

3 - Sets a broadcast policy for fault tolerance. All transmissions are sent on all slave interfaces.

4 - Sets an IEEE 802.3ad dynamic link aggregation policy. Creates aggregation groups that share the same speed and duplex settings. Transmits and receives on all slaves in the active aggregator. Requires a switch that is 802.3ad compliant.

5 - Sets a Transmit Load Balancing (TLB) policy for fault tolerance and load balancing. The outgoing traffic is distributed according to the current load on each slave interface. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed slave.

6 - Sets an Active Load Balancing (ALB) policy for fault tolerance and load balancing. Includes transmit and receive load balancing for IPV4 traffic. Receive load balancing is achieved through ARP negotiation.

需要注意的是MODE 0仅仅能实现网卡轮询,但同一时间只有一个网卡生效,总体带宽还是1个网卡的带宽。

这里,我们需要开启交换机的802.3ad,并设置mode=4来实现带宽增倍

具体测试方法参见:

http://sundog315.itpub.net/post/308/525631

注意,在上面这个BLOG里的mode需要改一下:

vi /etc/modprobe.conf

alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1

我们用iperf工具来测试带宽,由于mode 4模式使用mac地址分配那个网卡参与工作,因此,需要多台测试机进行测试

10.199.81.39作为server,10.199.81.40及10.199.81.42作为client,如果两个client均能达到1000Mbits,那也就意味着带宽是翻倍了。

server:

# iperf -s -w 1M
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 2.00 MByte (WARNING: requested 1.00 MByte)
------------------------------------------------------------
[ 4] local 10.199.81.39 port 5001 connected with 10.199.81.40 port 9951
[ 5] local 10.199.81.39 port 5001 connected with 10.199.81.42 port 61211
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec
[ 5] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec

达到了带宽翻倍的目的

[@more@]

# iperf -c 10.199.81.39 -w 1M -t 100 -i 2
------------------------------------------------------------
Client connecting to 10.199.81.39, TCP port 5001
TCP window size: 2.00 MByte (WARNING: requested 1.00 MByte)
------------------------------------------------------------
[ 3] local 10.199.81.40 port 9951 connected with 10.199.81.39 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 228 MBytes 956 Mbits/sec
[ 3] 2.0- 4.0 sec 226 MBytes 949 Mbits/sec
[ 3] 4.0- 6.0 sec 226 MBytes 948 Mbits/sec
[ 3] 6.0- 8.0 sec 227 MBytes 952 Mbits/sec
[ 3] 8.0-10.0 sec 226 MBytes 948 Mbits/sec
[ 3] 10.0-12.0 sec 226 MBytes 949 Mbits/sec
[ 3] 12.0-14.0 sec 226 MBytes 948 Mbits/sec
[ 3] 14.0-16.0 sec 226 MBytes 948 Mbits/sec
[ 3] 16.0-18.0 sec 227 MBytes 952 Mbits/sec
[ 3] 18.0-20.0 sec 226 MBytes 948 Mbits/sec
[ 3] 20.0-22.0 sec 226 MBytes 948 Mbits/sec
[ 3] 22.0-24.0 sec 227 MBytes 951 Mbits/sec
[ 3] 24.0-26.0 sec 226 MBytes 949 Mbits/sec
[ 3] 26.0-28.0 sec 226 MBytes 948 Mbits/sec
[ 3] 28.0-30.0 sec 226 MBytes 949 Mbits/sec
[ 3] 30.0-32.0 sec 226 MBytes 948 Mbits/sec
[ 3] 32.0-34.0 sec 227 MBytes 951 Mbits/sec
[ 3] 34.0-36.0 sec 226 MBytes 948 Mbits/sec
[ 3] 36.0-38.0 sec 226 MBytes 949 Mbits/sec
[ 3] 38.0-40.0 sec 226 MBytes 948 Mbits/sec
[ 3] 40.0-42.0 sec 227 MBytes 952 Mbits/sec
[ 3] 42.0-44.0 sec 226 MBytes 948 Mbits/sec
[ 3] 44.0-46.0 sec 226 MBytes 949 Mbits/sec
[ 3] 46.0-48.0 sec 226 MBytes 948 Mbits/sec
[ 3] 48.0-50.0 sec 226 MBytes 949 Mbits/sec
[ 3] 50.0-52.0 sec 227 MBytes 952 Mbits/sec
[ 3] 52.0-54.0 sec 226 MBytes 949 Mbits/sec
[ 3] 54.0-56.0 sec 226 MBytes 948 Mbits/sec
[ 3] 56.0-58.0 sec 226 MBytes 949 Mbits/sec
[ 3] 58.0-60.0 sec 226 MBytes 948 Mbits/sec
[ 3] 60.0-62.0 sec 227 MBytes 952 Mbits/sec
[ 3] 62.0-64.0 sec 226 MBytes 948 Mbits/sec
[ 3] 64.0-66.0 sec 226 MBytes 948 Mbits/sec
[ 3] 66.0-68.0 sec 226 MBytes 948 Mbits/sec
[ 3] 68.0-70.0 sec 226 MBytes 949 Mbits/sec
[ 3] 70.0-72.0 sec 227 MBytes 952 Mbits/sec
[ 3] 72.0-74.0 sec 226 MBytes 948 Mbits/sec
[ 3] 74.0-76.0 sec 226 MBytes 949 Mbits/sec
[ 3] 76.0-78.0 sec 226 MBytes 948 Mbits/sec
[ 3] 78.0-80.0 sec 226 MBytes 948 Mbits/sec
[ 3] 80.0-82.0 sec 227 MBytes 952 Mbits/sec
[ 3] 82.0-84.0 sec 226 MBytes 949 Mbits/sec
[ 3] 84.0-86.0 sec 226 MBytes 948 Mbits/sec
[ 3] 86.0-88.0 sec 226 MBytes 948 Mbits/sec
[ 3] 88.0-90.0 sec 226 MBytes 949 Mbits/sec
[ 3] 90.0-92.0 sec 227 MBytes 952 Mbits/sec
[ 3] 92.0-94.0 sec 226 MBytes 948 Mbits/sec
[ 3] 94.0-96.0 sec 226 MBytes 948 Mbits/sec
[ 3] 96.0-98.0 sec 226 MBytes 949 Mbits/sec
[ 3] 98.0-100.0 sec 227 MBytes 952 Mbits/sec
[ 3] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec

# iperf -c 10.199.81.39 -w 1M -t 100 -i 2
------------------------------------------------------------
Client connecting to 10.199.81.39, TCP port 5001
TCP window size: 2.00 MByte (WARNING: requested 1.00 MByte)
------------------------------------------------------------
[ 3] local 10.199.81.42 port 61211 connected with 10.199.81.39 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 228 MBytes 956 Mbits/sec
[ 3] 2.0- 4.0 sec 226 MBytes 949 Mbits/sec
[ 3] 4.0- 6.0 sec 226 MBytes 948 Mbits/sec
[ 3] 6.0- 8.0 sec 226 MBytes 948 Mbits/sec
[ 3] 8.0-10.0 sec 227 MBytes 952 Mbits/sec
[ 3] 10.0-12.0 sec 226 MBytes 949 Mbits/sec
[ 3] 12.0-14.0 sec 226 MBytes 948 Mbits/sec
[ 3] 14.0-16.0 sec 226 MBytes 949 Mbits/sec
[ 3] 16.0-18.0 sec 226 MBytes 948 Mbits/sec
[ 3] 18.0-20.0 sec 226 MBytes 949 Mbits/sec
[ 3] 20.0-22.0 sec 227 MBytes 952 Mbits/sec
[ 3] 22.0-24.0 sec 226 MBytes 948 Mbits/sec
[ 3] 24.0-26.0 sec 226 MBytes 948 Mbits/sec
[ 3] 26.0-28.0 sec 226 MBytes 948 Mbits/sec
[ 3] 28.0-30.0 sec 227 MBytes 952 Mbits/sec
[ 3] 30.0-32.0 sec 226 MBytes 948 Mbits/sec
[ 3] 32.0-34.0 sec 226 MBytes 948 Mbits/sec
[ 3] 34.0-36.0 sec 226 MBytes 948 Mbits/sec
[ 3] 36.0-38.0 sec 227 MBytes 952 Mbits/sec
[ 3] 38.0-40.0 sec 226 MBytes 948 Mbits/sec
[ 3] 40.0-42.0 sec 226 MBytes 949 Mbits/sec
[ 3] 42.0-44.0 sec 226 MBytes 948 Mbits/sec
[ 3] 44.0-46.0 sec 226 MBytes 949 Mbits/sec
[ 3] 46.0-48.0 sec 227 MBytes 951 Mbits/sec
[ 3] 48.0-50.0 sec 226 MBytes 948 Mbits/sec
[ 3] 50.0-52.0 sec 226 MBytes 949 Mbits/sec
[ 3] 52.0-54.0 sec 226 MBytes 948 Mbits/sec
[ 3] 54.0-56.0 sec 227 MBytes 951 Mbits/sec
[ 3] 56.0-58.0 sec 226 MBytes 948 Mbits/sec
[ 3] 58.0-60.0 sec 226 MBytes 948 Mbits/sec
[ 3] 60.0-62.0 sec 227 MBytes 952 Mbits/sec
[ 3] 62.0-64.0 sec 226 MBytes 948 Mbits/sec
[ 3] 64.0-66.0 sec 226 MBytes 948 Mbits/sec
[ 3] 66.0-68.0 sec 226 MBytes 948 Mbits/sec
[ 3] 68.0-70.0 sec 226 MBytes 949 Mbits/sec
[ 3] 70.0-72.0 sec 227 MBytes 952 Mbits/sec
[ 3] 72.0-74.0 sec 226 MBytes 948 Mbits/sec
[ 3] 74.0-76.0 sec 226 MBytes 948 Mbits/sec
[ 3] 76.0-78.0 sec 226 MBytes 949 Mbits/sec
[ 3] 78.0-80.0 sec 226 MBytes 949 Mbits/sec
[ 3] 80.0-82.0 sec 227 MBytes 951 Mbits/sec
[ 3] 82.0-84.0 sec 226 MBytes 948 Mbits/sec
[ 3] 84.0-86.0 sec 226 MBytes 949 Mbits/sec
[ 3] 86.0-88.0 sec 227 MBytes 951 Mbits/sec
[ 3] 88.0-90.0 sec 226 MBytes 949 Mbits/sec
[ 3] 90.0-92.0 sec 226 MBytes 948 Mbits/sec
[ 3] 92.0-94.0 sec 226 MBytes 949 Mbits/sec
[ 3] 94.0-96.0 sec 226 MBytes 948 Mbits/sec
[ 3] 96.0-98.0 sec 227 MBytes 951 Mbits/sec
[ 3] 98.0-100.0 sec 226 MBytes 948 Mbits/sec
[ 3] 0.0-100.0 sec 11.1 GBytes 949 Mbits/sec

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/19423/viewspace-1057750/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/19423/viewspace-1057750/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值