Centos7 网卡做 bond 以及 team

148 篇文章 2 订阅

实验环境:centos7 ,网卡 ens1,ens2

方法1:修改配置文件做 bond0 (证实有效)

1、创建 bond0 配置文件

[root@localhost sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
IPADDR=192.168.1.3
GATEWAY=192.168.1.1
PREFIX=24
IPV6INIT=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
BONDING_OPTS="mode=0"
DNS1=199.29.29.29
NDS2=223.5.5.5

2、修改网卡 em1、em2 配置文件

[root@localhost sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-em1
DEVICE=em1
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0          
SLAVE=yes
IPV6INIT=no
[root@localhost sysconfig]# cat /etc/sysconfig/network-scripts/ifcfg-em2
DEVICE=em2
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0          
SLAVE=yes
IPV6INIT=no

3、重启网络

systemctl restart network

4、检测

[root@localhost sysconfig]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:66:da:4d:c3:e8
Slave queue ID: 0

Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:66:da:4d:c3:e7
Slave queue ID: 0
方法2:使用 nmcli 命令做 bond1

网卡 eth0、eth1 做 bond1
1.添加 bond

 mcli connection add type bond con-name bond0 ifname bond0 mode active-backup ip4 172.25.254.136/24 

2.监测bond变动以及网络状态(新开一个终端)

watch -n 1 cat /proc/net/bonding/bond0

3.分别绑定两块网卡到bond上去:

nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0

4.通过停掉其中一块网卡观察bond反应以及网络变化

 ifconfig eth0 down       #停掉eth0
 nmcli connection delete eth0    #将eth0从bond解绑
 nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0    #加上eth0
 ifconfig eth1 down        #停掉eth1
方法3,使用 nmcli 命令做 team (证实有效)

1、设置绑定模式 loadbalance

nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"loadbalance"}}' 

3、设置 team0 的 ip,掩码,网关,手工模式

nmcli con modify team0 ipv4.addresses '10.2.5.117/24' ipv4.gateway '10.2.5.254' ipv4.method manual

4、将 em1 和 em2 分别加入 team0 组

nmcli con add type team-slave con-name team0-port1 ifname em1 master team0
nmcli con add type team-slave con-name team0-port2 ifname em2 master team0

5、查看网卡信息,若发现有橙色的要启动

nmcli con sh

6、若发现有橙色的要启动

nmcli con up team0

7、重启网络

systemctl restart network

8、查看服务启动,确保 active

systemctl status network
systemctl status NetworkManager

8、查看teaming绑定结果

teamdctl team0 st
ethtool team0
  • team 与 bond 区别

    team 可以理解为 bond 的升级

A Comparison of Features in Bonding and Team**

FeatureBondingTeam
broadcast Tx policyYesYes
round-robin Tx policyYesYes
active-backup Tx policyYesYes
LACP (802.3ad) supportYes (active only)Yes
Hash-based Tx policyYesYes
User can set hash functionNoYes
Tx load-balancing support (TLB)YesYes
LACP hash port selectYesYes
load-balancing for LACP supportNoYes
Ethtool link monitoringYesYes
ARP link monitoringYesYes
NS/NA (IPv6) link monitoringNoYes
ports up/down delaysYesYes
port priorities and stickiness (“primary” option enhancement)NoYes
separate per-port link monitoring setupNoYes
multiple link monitoring setupLimitedYes
lockless Tx/Rx pathNo (rwlock)Yes (RCU)
VLAN supportYesYes
user-space runtime controlLimitedFull
Logic in user-spaceNoYes
ExtensibilityHardEasy
Modular designNoYes
Performance overheadLowVery Low
D-Bus interfaceNoYes
multiple device stackingYesYes
zero config using LLDPNo(in planning)
NetworkManager supportYesYes

参考文章:

CentOS7 bonding配置

高级网络管理之bond与team

COMPARISON OF NETWORK TEAMING TO BONDING

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值