服务器做bond,交换机做port-channel

端口绑定的种类(具体介绍网上很多参考)

balance-rr or 0
active-backup or 1
balance-xor or 2
broadcast or 3
802.3ad or 4
balance-tlb or 5
balance-alb or 6

使用场景

高可用场景

上行一台交换机

参考增加带宽场景。因为如果交换机故障,则连接中断。若某链路故障,the bonding load balance modes
support link monitoring of their members,会自动切换。

上行两台交换机

TOPO如下

            |                                     |
            |port3                           port3|
      +-----+----+                          +-----+----+
      |          |port2       ISL      port2|          |
      | switch A +--------------------------+ switch B |
      |          |                          |          |
      +-----+----+                          +-----++---+
            |port1                           port1|
            |             +-------+               |
            +-------------+ host1 +---------------+
                     eth0 +-------+ eth1

这种模式下,只能选mode1(推荐)或者mode3(适用于某些特殊场景),其他模式需要对端连接到同一台设备。
链路监控选择 MII,ARP。MII简单,但不准确,除非交换机侧做"trunk failover." This is a feature of theswitch that causes the link state of a particular switch port to be setdown (or up) when the state of another switch port goes down (or up).。ARP需要配置target。

增加带宽场景

上行一台交换机(逻辑,如做了堆叠的两个交换机可以视为一个)

三层模式

 +----------+                     +----------+
 |          |eth0            port1|          | to other networks
 | Host A   +---------------------+ router   +------------------->
 |          +---------------------+          | Hosts B and C are out
 |          |eth1            port2|          | here somewhere
 +----------+                     +----------+

二层模式

+----------+            +----------+       +--------+
|          |eth0   port1|          +-------+ Host B |
|  Host A  +------------+  switch  |port3  +--------+
|          +------------+          |                  +--------+
|          |eth1   port2|          +------------------+ Host C |
+----------+            +----------+port4             +--------+

简而言之,由于许多负载均衡策略都和源MAC和目的MAC相关,三层模式下,目的MAC为gateway的MAC,二层模式下,目的MAC为通信对象HOSTB,HOSTC的MAC,这会带来一些区别。

模式选择

balance-rr or 0

这种模式是唯一可以做到让单个TCP流的带宽都增加的,但由于单个TCP流走两个不通链路,会带来包乱序的问题,包乱序会带来重传,严重时候直接reset。

active-backup or 1

这种模式在此场景下没啥优势,因为两条链路都连在同一个交换机上,在此场景下,loader blance模式会在带来相同可用性提升的基础上,提升带宽。但在交换机不支持负载均衡模式下有用。

balance-xor or 2

二层模式下可以使用,三层模式下不推荐。

broadcast or 3

同 mode 1

802.3ad or 4

推荐使用。通常交换机都支持,问题是三层模式也可能导致流量不均衡。只支持MII监视器。

balance-tlb or 5

三层模式也会导致流量不均衡,与mode4不同的是,salve设备可以是不同的速率,不用交换机特殊配置。

balance-alb or 6

同mode5,并且需要驱动支持修改MAC地址。

上行多台交换机

                   +-----------+
                   |  Host A   | 
                   +-+---+---+-+
                     |   |   |
            +--------+   |   +---------+
            |            |             |
     +------+---+  +-----+----+  +-----+----+
     | Switch A |  | Switch B |  | Switch C |
     +------+---+  +-----+----+  +-----+----+
            |            |             |
            +--------+   |   +---------+
                     |   |   |
                   +-+---+---+-+
                   |  Host B   | 
                   +-----------+

模式选择

一般选择balance-rr。

某项目在华为堆叠,服务器配置mode5的情况下,(交换机侧配不配置port-channel一样)丢包。待项目重启后尝试更改服务器侧为mode4试试。

交换机侧

[DeviceA] interface bridge-aggregation 1

[DeviceA-Bridge-Aggregation1] quit

分别将端口GigabitEthernet1/0/1至 GigabitEthernet1/0/3加入到聚合组1中。

[DeviceA] interface gigabitethernet 1/0/1

[DeviceA-gigabitethernet1/0/1] port link-aggregation group 1

[DeviceA-gigabitethernet1/0/1] quit

[DeviceA] interface gigabitethernet 1/0/2

[DeviceA-gigabitethernet1/0/2] port link-aggregation group 1

[DeviceA-gigabitethernet1/0/2] quit

[DeviceA] interface gigabitethernet 1/0/3

[DeviceA-gigabitethernet1/0/3] port link-aggregation group 1

[DeviceA-gigabitethernet1/0/3] quit
[DeviceA] interface bridge-aggregation 1

[DeviceA-Bridge-Aggregation1] port link-type access vlan 10 待测试

参考:
https://www.kernel.org/doc/Documentation/networking/bonding.txt
https://en.wikipedia.org/wiki/EtherChannel
http://www.h3c.com/cn/d_201108/723394_30005_0.htm#_Toc301162087

posted on 2022-05-07 17:59  yangras  阅读(558)  评论(0)    收藏  举报

导航