linux下网卡bond配置

发布时间:2019-03-14 13:12:23   来源:文档文库   
字号:

Linux 7.x OS bond配置

一、bonding技术

bonding(绑定)是一种linux系统下的网卡绑定技术,可以把服务器上n个物理网卡在系统内部抽象(绑定)成一个逻辑上的网卡,能够提升网络吞吐量、实现网络冗余、负载等功能,有很多优势。

bonding技术是linux系统内核层面实现的,它是一个内核模块(驱动)。使用它需要系统有这个模块, 我们可以modinfo命令查看下这个模块的信息, 一般来说都支持.

# modinfo bonding

filename: /lib/modules/2.6.32-642.1.1.el6.x86_64/kernel/drivers/net/bonding/bonding.ko

author: Thomas Davis, tadavis@lbl.gov and many others

description: Ethernet Channel Bonding Driver, v3.7.1

version: 3.7.1

license: GPL

alias: rtnl-link-bond

srcversion: F6C1815876DCB3094C27C71

depends:

vermagic: 2.6.32-642.1.1.el6.x86_64 SMP mod_unloadmodversions

parm: max_bonds:Max number of bonded devices (int)

parm: tx_queues:Max number of transmit queues (default = 16) (int)

parm: num_grat_arp:Number of peer notifications to send on failover event (alias of num_unsol_na) (int)

parm: num_unsol_na:Number of peer notifications to send on failover event (alias of num_grat_arp) (int)

parm: miimon:Link check interval in milliseconds (int)

parm: updelay:Delay before considering link up, in milliseconds (int)

parm: downdelay:Delay before considering link down, in milliseconds (int)

parm: use_carrier:Usenetif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default) (int)

parm: mode:Mode of operation; 0 for balance-rr, 1 for active-backup, 2 for balance-xor, 3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, 6 for balance-alb (charp)

parm: primary:Primary network device to use (charp)

parm: primary_reselect:Reselect primary slave once it comes up; 0 for always (default), 1 for only if speed of primary is better, 2 for only on active slave failure (charp)

parm: lacp_rate:LACPDUtx rate to request from 802.3ad partner; 0 for slow, 1 for fast (charp)

parm: ad_select:803.ad aggregation selection logic; 0 for stable (default), 1 for bandwidth, 2 for count (charp)

parm: min_links:Minimum number of available links before turning on carrier (int)

parm: xmit_hash_policy:balance-xor and 802.3ad hashing method; 0 for layer 2 (default), 1 for layer 3+4, 2 for layer 2+3 (charp)

parm: arp_interval:arp interval in milliseconds (int)

parm: arp_ip_target:arp targets in n.n.n.n form (array of charp)

parm: arp_validate:validatesrc/dst of ARP probes; 0 for none (default), 1 for active, 2 for backup, 3 for all (charp)

parm: arp_all_targets:fail on any/all arp targets timeout; 0 for any (default), 1 for all (charp)

parm: fail_over_mac:For active-backup, do not set all slaves to the same MAC; 0 for none (default), 1 for active, 2 for follow (charp)

parm: all_slaves_active:Keep all frames received on an interface by setting active flag for all slaves; 0 for never (default), 1 for always. (int)

parm: resend_igmp:Number of IGMP membership reports to send on link failure (int)

parm: packets_per_slave:Packets to send per slave in balance-rr mode; 0 for a random slave, 1 packet per slave (default), >1 packets per slave. (int)

parm: lp_interval:The number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch. The default is 1. (uint)

modinfo bonding

bonding的七种工作模式:

bonding技术提供了七种工作模式,在使用的时候需要指定一种,每种有各自的优缺点.

1.balance-rr (mode=0) 默认, 有高可用 (容错) 和负载均衡的功能, 需要交换机的配置,每块网卡轮询发包 (流量分发比较均衡).

2.active-backup (mode=1) 只有高可用 (容错) 功能, 不需要交换机配置, 这种模式只有一块网卡工作, 对外只有一个mac地址。缺点是端口利用率比较低

3.balance-xor (mode=2) 不常用

4.broadcast (mode=3) 不常用

5.802.3ad (mode=4) IEEE 802.3ad 动态链路聚合,需要交换机配置

6.balance-tlb (mode=5) 不常用

7.balance-alb (mode=6) 有高可用 ( 容错 )和负载均衡的功能,不需要交换机配置 (流量分发到每个接口不是特别均衡)

具体的网上有很多资料,了解每种模式的特点根据自己的选择就行, 一般会用到0146这几种模式。

1. 我们先看主备模式

主备模式下,Linux Bonding实现会将Bond的两个slave网口的MAC地址改为BondMAC地址,而BondMAC地址是Bond创建启动后,主用slave网口的MAC地址。

2. 再看负载均衡模式

负载均衡模式下,Linux Bonding实现可以保持两个slave网口的MAC地址不变,BondMAC地址是其中一个网卡的,Bond MAC地址的选择是根据Bond自己实现的一个算法来的

3.链路聚合是在两个设备间使用多个物理链路创建一个逻辑链路的功能。这种方式允许物理链路间共享负载。

#ethtoolp ethX查看具体对应网卡

[root@localhost bonding]# watch -n 1 cat /proc/net/bonding/nm-bond ####测试的监控命令

#nmcli connection add con-name bond0 type bond mode active-backup ip4 172.25.254.121/24 #####创建一个bound0

#nmcli connection add con-name ens3 ifname ens3 type bond-slave master bond0

#######ens3加入到bound0

#nmcli connection add con-name ens8 ifname ens8 type bond-slave master bond0

#######ens8加入到bound0

# nmcli connection up bond-slave-eno1

# nmcli connection up bond-slave-eno2

#nmcli connection up bond0

#ifconfig eth0 down

# ifconfig eth0 up

[root@localhost bonding]#ifconfig eth1 down

######在网卡关闭和开启时时bound0的变化

本文来源:https://www.2haoxitong.net/k/doc/6796a7510166f5335a8102d276a20029bd64639d.html

《linux下网卡bond配置.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档

文档为doc格式