服务器bonding

it2022-05-05  178

服务器bonding

server

cat /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0 IPADDR=211.98.243.231 NETMASK=255.255.255.224 ONBOOT=yes BOOTPROTO=none USERCTL=no BONDING_OPTS="mode=4 miimon=100 xmit_hash_policy=layer3+4" mode=4 支持802.3ad(LACP)模式的负载均衡 miimon=100 xmit_hash_policy=1(layer3+4) 可以超过物理端口带宽

cat /etc/sysconfig/network-scripts/ifcfg-ethX

DEVICE=ethX ONBOOT=yes BOOTPROTO=none USERCTL=no MASTER=bond0 SLAVE=yes

switch

#force10 Create a LAG Force10(conf)#interface port-channel 1 Force10(conf-if-po-32)#no shutdown Force10(conf-if-po-32)#switchport Force10(conf)#interface port-channel 2 Force10(conf-if-po-32)#no shutdown Force10(conf-if-po-32)#switchport Force10(conf)#interface port-channel 3 Force10(conf-if-po-32)#no shutdown Force10(conf-if-po-32)#switchport Force10(conf)#interface vlan 2 Force10(conf-if-vl-10)#untagged port-channel 1 Force10(conf-if-vl-10)#untagged port-channel 2 Force10(conf-if-vl-10)#untagged port-channel 3 # untagged用于服务器互联, tagged用于交换机互联 interface vlan 2 no untagged gigabitethernet 0/27-28 exit interface range gigabitethernet 0/27 - 28 no switchport shutdown port-channel-protocol lacp port-channel 2 mode active no shutdown exit interface vlan 2 no untagged gigabitethernet 0/25-26 exit interface range gigabitethernet 0/25 - 26 no switchport shutdown port-channel-protocol lacp port-channel 1 mode active no shutdown exit #dell n3048 create vlan vlan 10 exit create LAG interface port-channel 1 switchport access vlan 10 exit interface Gi1/0/25 channel-group 1 mode active switchport access vlan 10 exit interface Gi1/0/26 channel-group 1 mode active switchport access vlan 10 exit #dell2848 Switch -> ports -> LAG Configuration Load Balance -> Layer 2-3 (mac & ip) Switch g25, g26 -> lag 1 g27, g28 -> lag 2 g29, g30 -> lag 3

bond mode 参数

mode=0 or mode=balance-rr Round-robin策略:从头到尾顺序的在每一个slave接口上面发送数据包。 本模式提供负载均衡和容错的能力。 mode=1 or mode=active-backup 主备策略:在绑定中,只有一个slave被激活。当且仅当活动的slave接口失败时才会激活其他slave。为了避免交换机发生混乱此时绑定的MAC地址只有一个外部端口上可见。 在bongding的2.6.2及其以后的版本中,主备模式下发生一次故障迁移时,bonding将在新激活的slave上会送一个或者多个gratuitous ARP.bonding的主salve接口上以及配置在接口上的所有VLAN接口都会发送gratuitous ARP,只要这些接口上配置了至少一个IP地址。VLAN接口上发送的的gratuitous ARP将会附上适当的VLAN id。 本模式提供容错能力,primary option,documented below会影响本模式的行为。 mode=2 or mode=balance-xor XOR策略:基于所选择的传送hash策略。 本模式提供负载均衡和容错的能力。 mode=3 or mode=broadcast 广播策略:在所有的slave接口上传送所有的报文。 本模式提供容错能力。 mode=4 or mode=802.3ad IEEE 802.3ad 动态链路聚合。创建共享相同的速率和双工模式的聚合组。能根据802.3ad规范利用所有的slave来建立聚合链路。 Salve的出站选择取决于传输的hash策略,默认策略是简单的XOR策略,而hash策略则可以通xmit_hash_policy选项加以改变。 需要注意的是:不是所有的传输策略都与802.3ad兼容,尤其是802.3ad标准的43.2.4章节中关于 packet mis-ordering要求的地方。不同个体的实现往往出现很大的不兼容。 先决条件: 1. 每个slave的基本驱动支持Ehtool获取速率和双工状态。 2. 交换机支持IEEE 802.3ad动态链路聚合。大多数的交换机都需要使用某种配置方式来启用802.3ad模式。 mode=5 or mode=balance-tlb 自适应传输负载均衡:信道绑定不需要特殊的交换机支持。出口流量的分布取决于当前每个slave的负载(计算相对速度)。进口流量从当前的slave的接收。如果接收salve出错,其他的slave接管失败的slave的MAC地址继续接收。 先决条件: 每个slave的基本驱动支持Ehtool获取速率状态。 mode=6 or mode=balance-alb 自适应负载均衡:包括balance-tlb(模式5)以及用于IPV4流量的接收负载均衡,并且不需要特殊的交换机支持。接收负载均衡通过ARP协商实现。bonding的驱动拦截本机发出的ARP Replies(ARP回应报文),并且用bond的某一个slave的硬件地址改写ARP报文的源地址,使得本服务器对不同的设备使用不同的硬件地址。本服务器建立的连接的接收流量也是负载均衡的。当本机发送ARP Request时,bonding驱动通过ARP报文复制并保存节点的IP信息。当从其他节点接收到ARP Reply,bonding驱动获取节点的硬件地址并且会回应一个包含绑定好的slave的硬件地址的ARP Reply给发送的节点。用ARP协商的负载均衡的有一个问题是每次用bond的硬件地址广播ARP报文,那么其他节点发送的数据全部集中在一个slave上,处理ARP更新给其他所有节点的时候,每个节点会重新学习硬件地址,导致流量重新分配。当新加入一个slave或者一个非激活的slave重新激活的时候也会导致接收流量重新分配。接收流量负载是串行(轮转)的分配在bond的一组速率最高的slave上。 当一个链路重连或者一个新的slave加入的时候,bond会重新初始化ARP Replies给所有的客户端。updelay参数的值必须等于或者大于交换机的forwarding delay,以免ARP Replies被交换机阻塞。 先决条件: 1.每个slave的基本驱动支持Ehtool获取速率状态。 2.基本驱动支持当设备打开时重新设置硬件地址。也要求每一个slave具有唯一的硬件地址。如果curr_active_slave失败,它的硬件地址被新选上的curr_active_slave硬件地址来替换。 # The active-backup, balance-tlb and balance-alb modes do not require any specific configuration of the switch. XOR策略 xmit_hash_policy=0 or xmit_hash_policy=layer2 layer2 (0): (source MAC XOR destination MAC) modulo slave count xmit_hash_policy=2 or xmit_hash_policy=layer3 layer2+3 (2): (((source IP XOR dest IP) AND 0xffff) XOR ( source MAC XOR destination MAC )) modulo slave count xmit_hash_policy=1 or xmit_hash_policy=layer3+4 layer3+4 (1): ((source port XOR dest port) XOR ((source IP XOR dest IP) AND 0xffff) modulo slave count # 为了能更加均衡,可采用mac&ip异或哈希 posted on 2014-10-19 11:10 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/4034425.html


最新回复(0)