网卡数据链路层负载均衡是使用mode4,且可以实现物理链路间互备,提供给用户的是一个逻辑上的链路,该逻辑链路的有效网络带宽为全部物理链路带宽之和。
Bonding mode4的一些特性:
最多支持绑定8个主机的网卡端口;
LACP控制协议数据包每秒发送一次,检测主机网卡是否存活的检测包每30秒(fast)或每秒(slow)发送一次;
LACP mode:active或passive,默认为passive模式,即只有当探测到有支持LACP功能的设备时自己才启用LACP功能;
对Bonding mode4的理解可以参考下面的链接。
1、Bonding的模式一共有7种
#defineBOND_MODE_ROUNDROBIN 0 (balance-rr模式)网卡的负载均衡模式
#defineBOND_MODE_ACTIVEBACKUP 1 (active-backup模式)网卡的容错模式
#defineBOND_MODE_XOR 2 (balance-xor模式)需要交换机支持
#defineBOND_MODE_BROADCAST 3 (broadcast模式)
#defineBOND_MODE_8023AD 4 (IEEE 802.3ad动态链路聚合模式)需要交换机支持
#defineBOND_MODE_TLB 5 自适应传输负载均衡模式
#defineBOND_MODE_ALB 6 网卡虚拟化方式
bonding模块的所有工作模式可以分为两类:多主型工作模式和主备型工作模式,balance-rr 和broadcast属于多主型工作模式而active-backup属于主备型工作模式。(balance-xor、自适应传输负载均衡模式(balance-tlb)和自适应负载均衡模式(balance-alb)也属于多主型工作模式,IEEE 802.3ad动态链路聚合模式(802.3ad)属于主备型工作模式。
2、加载并查看bonding模块
可以使用modinfo bonding 命令查看bonding模块的信息,默认情况下bonding模块没有被加载
可以以root用户登录,输入如下的命令进行开启加载bonding模块
modprobe bonding
modinfo bonding
lsmod | grep 'bonding'
3、修改网卡配置文件
创建/etc/sysconfig/network-scripts/ifcfg-bond0文件,加入如下内容:
DEVICE=bond0
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=10.10.7.2
PREFIX=24
GATEWAY=192.168.120.1
ONBOOT=yes
BOOTPROTO=static
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1"
注:mode=4,设置为链路负载均衡模式;miimon=100,监控网线链路故障的时间间隔(毫秒);lacp_rate=1,检测主机网卡是否存活的检测包每30秒(fast)或每秒(slow)发送一次。
修改/etc/sysconfig/network-scripts/ifcfg-ens27f0文件:
DEVICE=ens27f0
TYPE=Ethernet
BOOTPROTO=static
NAME=ens27f0
ONBOOT=yes
MASTER=bond0
SLAVE=yes
修改/etc/sysconfig/network-scripts/ifcfg-ens27f1文件:
DEVICE=ens27f1
TYPE=Ethernet
BOOTPROTO=static
NAME=em2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
在主机上确认配置结果方法:
#cat /proc/net/bonding/bond0
#ethtool bond0
注意查看Speed是否是2000Mb/s
[root@localhost ~]# ethtool bond0
Settings for bond0:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 2000Mb/s
Duplex: Full
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes
[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Peer Notification Delay (ms): 0
802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
System priority: 65535
System MAC address: b4:05:5d:fc:66:7f
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 9
Partner Key: 4
Partner Mac Address: 80:61:6c:c8:38:90
Slave Interface: ens27f0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: b4:05:5d:fc:66:7f
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: b4:05:5d:fc:66:7f
port key: 9
port priority: 255
port number: 1
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: 80:61:6c:c8:38:90
oper key: 4
port priority: 32768
port number: 7
port state: 61
Slave Interface: ens27f1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: b4:05:5d:fc:66:80
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 65535
system mac address: b4:05:5d:fc:66:7f
port key: 9
port priority: 255
port number: 2
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: 80:61:6c:c8:38:90
oper key: 4
port priority: 32768
port number: 8
port state: 61
[root@localhost ~]#
系统服务NetworkManager 没有关闭,网上好多说要关闭,我这边测CENTOS8.没有影响
标签:bond4,priority,mode4,centos8.2,模式,网卡,bonding,链路,port From: https://www.cnblogs.com/qindongdong/p/18101637