Linux 中各通道绑定模式有何区别?

Linux 中各通道绑定模式有何区别?

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

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

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

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

答案1

  1. 故障转移的最大因素是检测到链接故障的速度。从主机上拔下电缆,它们都会正常工作。在原本死机的交换机上留下一个活动链接,大多数模式(支持信标/保持活动的模式除外)都会将部分流量发送到无处可去。

  2. 一般而言,网络流量是由中断驱动的。各种哈希算法不会产生任何有意义的差异。

  3. 任何非主动/待机或广播模式都将在不同程度上共享流量。某些模式可以基于每个数据包进行平衡,其他模式则基于每个流进行平衡。前者将更均匀地分散负载,而后者在实际网络中更有用(即功能性/稳定性)。

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

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

  6. 在生产中我倾向于信任的唯一模式是 802.3ad,通过适当配置的交换机,它将确保只有正确的链路才会进入通道,并在流量共享中提供一定程度的对称性,并在链路断开时提供可预测的响应。此模式还可以避免一些常见但令人讨厌的问题(即单播泛洪)。主动/备用模式也相当常见。其他模式在某些情况下可能是必需的,但在我看来,它们往往更麻烦。

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

答案2

您最喜欢的发行版的 Linux 源包的文档文件中对上述大多数要点进行了非常详尽的描述/usr/src/linux/Documentation/networking/bonding.txt。大多数模式下的故障转移速度由“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.

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

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

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

balance-xor 可能需要也可能不需要交换机配置。您需要设置一个接口组(不是HP 和 Cisco 交换机上支持 LACP(Layer Law Contains Control Protocol,链路控制协议),但 D-Link、Netgear 和 Fujitsu 交换机上显然没有必要使用 LACP。

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

注意:无论你做什么,一个网络连接总是通过一个且只有一个物理链路。因此,当聚合 GigE 接口时,从机器 A 到机器 B 的文件传输不能超过 1 千兆位/秒,即使每台机器都有 4 个聚合 GigE 接口(无论使用哪种绑定模式)。

答案3

内核文档回答了其中一些问题:

以太网绑定

相关内容