Linux--多网卡的7种Bond模式和交换机配置

摘要:
绑定模式:模式=0表示负载共享循环,与交换机的聚合和强制非协商相协调。5和6不需要在交换机侧设置,并且可以自动聚合网卡。理论上,0、2和3需要静态聚合,但在实践中,0可以在不通过MAC地址欺骗设置交换机的情况下不均匀地接收。有三种常用模式=0:负载平衡模式、自动备份,但需要“交换机”支持和设置。交换机不需要配置为mode6模式,因为用于绑定的两个网卡使用不同的MAC地址。

网卡bond是通过把多张网卡绑定为一个逻辑网卡,实现本地网卡的冗余,带宽扩容和负载均衡。在应用部署中是一种常用的技术,我们公司基本所有的项目相关服务器都做了bond,这里总结整理,以便待查。

bond模式:

  1. Mode=0(balance-rr) 表示负载分担round-robin,和交换机的聚合强制不协商的方式配合。
  2. Mode=1(active-backup) 表示主备模式,只有一块网卡是active,另外一块是备的standby,这时如果交换机配的是捆绑,将不能正常工作,因为交换机往两块网卡发包,有一半包是丢弃的。
  3. Mode=2(balance-xor) 表示XOR Hash负载分担,和交换机的聚合强制不协商方式配合。(需要xmit_hash_policy)
  4. Mode=3(broadcast) 表示所有包从所有interface发出,这个不均衡,只有冗余机制...和交换机的聚合强制不协商方式配合。
  5. Mode=4(802.3ad) 表示支持802.3ad协议,和交换机的聚合LACP方式配合(需要xmit_hash_policy)
  6. Mode=5(balance-tlb) 是根据每个slave的负载情况选择slave进行发送,接收时使用当前轮到的slave
  7. Mode=6(balance-alb) 在5的tlb基础上增加了rlb。

5和6不需要交换机端的设置,网卡能自动聚合。4需要支持802.3ad。0,2和3理论上需要静态聚合方式
但实测中0可以通过mac地址欺骗的方式在交换机不设置的情况下不太均衡地进行接收。

常用的有三种

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。

mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。

mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

需要说明的是如果想做成mode 0的负载均衡,仅仅设置这里options bond0 miimon=100 mode=0是不够的,与网卡相连的交换机必须做特殊配置(这两个端口应该采取聚合方式),因为做bonding的这两块网卡是使用同一个MAC地址.从 原理分析一下(bond运行在mode 0下):

mode 0下bond所绑定的网卡的IP都被修改成相同的mac地址,如果这些网卡都被接在同一个交换机,那么交换机的arp表里这个mac地址对应的端口就有 多 个,那么交换机接受到发往这个mac地址的包应该往哪个端口转发呢?正常情况下mac地址是全球唯一的,一个mac地址对应多个端口肯定使交换机迷惑 了。所以 mode0下的bond如果连接到交换机,交换机这几个端口应该采取聚合方式(cisco称 为 ethernetchannel,foundry称为portgroup),因为交换机做了聚合后,聚合下的几个端口也被捆绑成一个mac地址.我们 的解 决办法是,两个网卡接入不同的交换机即可。

mode6模式下无需配置交换机,因为做bonding的这两块网卡是使用不同的MAC地址。

来段英文的

  • mode=0 (Balance Round Robin) per packet
  • mode=1 (Active backup)
  • mode=2 (Balance XOR)
  • mode=3 (Broadcast)
  • mode=4 (802.3ad)
  • mode=5 (Balance TLB)
  • mode=6 (Balance ALB)

Modes of bonding :

RHEL bonding supports 7 possible “modes” for bonded interfaces. These modes determine the way in which traffic sent out of the bonded interface is actually dispersed over the real interfaces. Modes 0, 1, and 2 are by far the most commonly used among them.
    • Mode 0 (balance-rr)
      This mode transmits packets in a sequential order from the first available slave through the last. If two real interfaces are slaves in the bond and two packets arrive destined out of the bonded interface the first will be transmitted on the first slave and the second frame will be transmitted on the second slave. The third packet will be sent on the first and so on. This provides load balancing and fault tolerance.
    • Mode 1 (active-backup)
      Mode 1 places one of the interfaces into a backup state and will only make it active if the link is lost by the active interface. Only one slave in the bond is active at an instance of time. A different slave becomes active only when the active slave fails. This mode provides fault tolerance.
    • Mode 2 (balance-xor)
      Transmits based on XOR formula. (Source MAC address is XOR’d with destination MAC address) modula slave count. This selects the same slave for each destination MAC address and provides load balancing and fault tolerance.
    • Mode 3 (broadcast)
      The broadcast mode transmits everything on all slave interfaces. This mode is least used (only for a specific purpose) and provides only fault tolerance.
    • Mode 4 (802.3ad)
      The 802.3ad mode is known as Dynamic Link Aggregation mode. It creates aggregation groups that share the same speed and duplex settings. This mode requires a switch that supports IEEE 802.3ad Dynamic link. 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 in regards 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.
    • Mode 5 (balance-tlb)
      This is called as Adaptive transmit load balancing. The outgoing traffic is distributed according to the current load and queue on each slave interface. Incoming traffic is received by the current slave.
    • Mode 6 (balance-alb)
      This is Adaptive load balancing mode. This includes balance-tlb + receive load balancing (rlb) for IPV4 traffic. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the server on their way out and overwrites the src hw address with the unique hw address of one of the slaves in the bond such that different clients use different hw addresses for the server.

参考链接

https://www.cnblogs.com/lcword/p/5914089.html

https://www.cloudibee.com/network-bonding-modes/

免责声明:文章转载自《Linux--多网卡的7种Bond模式和交换机配置》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇信贷业务(Ali)MySQL-快速入门(11)用户管理下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Linux系统编程——水平触发和边沿触发

事件模型 Edge Triggered (ET) 边缘触发只有数据到来,才触发,不管缓存区中是否还有数据。 Level Triggered (LT) 水平触发只要有数据都会触发。 首先介绍一下LT工作模式: LT(level triggered)是缺省的工作方式,并且同时支持block和no-block socket.在这种做法中,内核告诉你一个文件描述符...

linux 查看系统资源使用信息的一些命令集合

linux上的进程查看及管理工具: pstree,ps,pidof,pgrep,top,htop,glances,pmap,vmstat,dstat,kill,pkill,job,bg,fg,nohup,nice,renice,killall。。。 linux开机时,会启动第一个进程,由这个进程去启动别的进程,这个第一个进程在centos5,6,7上实现的...

【Linux】 源码安装make命令详解,避免踩坑

正常的编译安装/卸载: 源码的安装一般由3个步骤组成:配置(configure)、编译(make)、安装(make install)。   configure文件是一个可执行的脚本文件,它有很多选项,在待安装的源码目录下使用命令./configure –help可以输出详细的选项列表。   其中--prefix选项是配置安装目录,如果不配置该选项,安装后可...

linux内核驱动中对文件的读写 【转】

本文转载自:http://blog.chinaunix.net/uid-13059007-id-5766941.html 有时候需要在Linux kernel--大多是在需要调试的驱动程序--中读写文件数据。在kernel中操作文件没有标准库可用,需要利用kernel的一些函数,这些函数主 要有: filp_open() filp_close(), vfs...

【嵌入式开发】 嵌入式开发工具简介 (裸板调试示例 | 交叉工具链 | Makefile | 链接器脚本 | eclipse JLink 调试环境)

作者 : 韩曙亮 博客地址 : http://blog.csdn.net/shulianghan/article/details/42239705  参考博客 : 【嵌入式开发】嵌入式 开发环境 (远程登录 | 文件共享 | NFS TFTP 服务器 | 串口连接 | Win8.1 + RedHat Enterprise 6.3 + Vmware11)...

linux安装mvn后提示权限不够

Maven - 环境配置 Maven 是一个基于 Java 的工具,所以要做的第一件事情就是安装 JDK。 系统要求 项目 要求 JDK Maven 3.3 要求 JDK 1.7 或以上Maven 3.2 要求 JDK 1.6 或以上Maven 3.0/3.1 要求 JDK 1.5 或以上 内存 没有最低要求 磁盘 Maven 自身安装需...