Linux 中的通道绑定模式有什么区别?

hoo*_*enz 9 linux ethernet bonding

在 Linux 下,您可以将多个网络接口组合成一个“绑定”网络接口以提供故障转移。

但是有几种模式,其中一些不需要交换机支持。我的开关不受限制,因为我可以使用任何模式。

然而,在阅读不同模式时,并不能立即清楚每种模式的优缺点。

  1. 某些模式是否提供更快的故障转移?
  2. 每种模式对 CPU 负载的影响如何?
  3. 哪些模式可以结合带宽而不仅仅是提供冗余?
  4. 有限制吗?
  5. balance-rr 是否需要交换机支持?
  6. 可靠性?长期跑步有什么经验?

waz*_*oox 11

这些要点中的大部分内容在/usr/src/linux/Documentation/networking/bonding.txt您最喜欢的发行版的 linux 源包中的文档文件中都有非常详尽的描述。对于大多数模式,故障转移速度由“miimon”参数控制,但不应设置得太低;无论如何,正常值都低于一秒。

以下是最好的部分,由我完成:

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


   active-backup or 1
       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.

   balance-xor or 2
       XOR policy: Transmit based on the selected transmit
       hash policy.  The default policy is a simple [(source
       MAC address XOR'd with destination MAC address) modulo
       slave count].  Alternate transmit policies may be
       selected via the xmit_hash_policy option.

       This mode provides load balancing and fault tolerance.

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

   802.3ad or 4
       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.

       Slave selection for outgoing traffic is done according
       to the transmit hash policy, which may be changed from
       the default simple XOR policy via the xmit_hash_policy
       option. Note that not all transmit policies may be 802.3ad
       compliant, particularly inregards to the packet mis-ordering
       requirements of section 43.2.4 of the 802.3ad standard.
       Differing peer implementations will have varying tolerances for
       noncompliance.

       Note: Most switches will require some type of configuration
       to enable 802.3ad mode.

   balance-tlb or 5
       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.

   balance-alb or 6
       Adaptive load balancing: includes balance-tlb plus
       receive load balancing (rlb) for IPV4 traffic, and
       does not require any special switch support.

       When a link is reconnected or a new slave joins the
       bond the receive traffic is redistributed among all
       active slaves in the bond by initiating ARP Replies
       with the selected MAC address to each of the
       clients. The updelay parameter must
       be set to a value equal or greater than the switch's
       forwarding delay so that the ARP Replies sent to the
       peers will not be blocked by the switch.
Run Code Online (Sandbox Code Playgroud)

balance-rr、active-backup、balance-tlb 和 balance-alb 不需要交换机支持。

balance-rr 以碎片为代价增强性能,在某些协议 (CIFS) 和超过 2 个接口的情况下表现不佳。

balance-alb 和 balance-tlb 可能无法在所有开关上正常工作;经常有一些 arp 问题(例如,某些机器可能无法相互连接)。您可能需要调整各种设置(miimon、updelay)以获得稳定的网络。

balance-xor 可能需要也可能不需要交换机配置。您需要在 HP 和 Cisco 交换机上设置接口组(不是LACP),但显然在 D-Link、Netgear 和 Fujitsu 交换机上不需要。

802.3ad 绝对需要交换机端的 LACP 组。它是增强性能的最佳支持选项。

注意:无论你做什么,一个网络连接总是通过一个而且只有一个物理链接。所以在聚合 GigE 接口时,从机器 A 到机器 B 的文件传输不能超过 1 Gb/s,即使每台机器有 4 个聚合的 GigE 接口(无论使用什么绑定模式)。


rnx*_*xrx 10

  1. 故障转移的最大因素是检测链路故障的速度。从主机上拔下电缆,它们都会很好地工作。在其他情况下死机的开关上留下实时链接,并且大多数模式(支持信标/keepalive 的模式除外)将无处发送您的部分流量。

  2. 一般来说,网络流量是由中断驱动的。各种散列算法不会产生有意义的差异。

  3. 任何非活动/备用或全广播的模式都将在不同程度上共享流量。一些模式可以在每个数据包的基础上进行平衡,其他模式则在每个流的基础上工作。前者将更均匀地分散负载,而后者在实际网络中更有用(阅读:功能/稳定)。

  4. 是的 - 每种模式都有限制,但我们需要更多地了解您的应用程序才能与他们交谈。

  5. 只有 LACP/802.3ad(模式 4)明确要求交换机支持。也就是说,仅仅因为您使用特定模式发送到交换机并不意味着交换机将以相同的方式发送回给您。

  6. 我在生产中倾向于信任的唯一模式是 802.3ad,通过适当配置的交换机,它将确保只有正确的链接最终进入通道,并在流量共享中提供某种对称性措施,并在出现以下情况时提供可预测的响应链接挂了。这种模式还避免了一些常见但令人讨厌的问题(即单播泛洪)。主用/备用也很常见。在某些情况下可能需要其他模式,但 IMO 往往更痛苦。

其他基于流/MAC/IP 的平衡模式或活动/备用也可以,并且在处理非托管交换机时可能需要。