网卡的链路聚合就是将多块网卡连接起来,当一块网卡损坏,网络依旧可以正常运行,可以有效的防止因为网卡损坏带来的损失,同时也可以提高网络访问速度。
网卡的链路聚合方式:
1,bond:最多可以添加两块网卡
2,team:最多可以添加八块网卡
bond的常用的2种模式:
1 Centos7/RHEL7配置bond0
[[email protected] ~]# nmcli device
//创建bond0, 模式为balance-rr
[[email protected] ~]# nmcli connection add type bond mode balance-rr con-name bond0 ifname bond0 ipv4.method manual ipv4.addresses 172.16.12.250/24 ipv4.gateway 172.16.12.2 ipv4.dns 172.16.12.2
Connection ‘bond0’ (83b7b2c9-fd9f-45e4-b6aa-512774cc6808) successfully added.
//添加物理网卡连接至bond0
[[email protected] ~]# nmcli connection add type bond-slave con-name bond-slave0 ifname eth0 master bond0
Connection ‘bond-slave0’ (5642affa-217d-4e48-ac6c-6043f1657361) successfully added.
[[email protected] ~]# nmcli connection add type bond-slave con-name bond-slave1 ifname eth1 master bond0
Connection ‘bond-slave1’ (1ef9017f-4b0d-46bf-95a1-f31be9353234) successfully added.
//查看bond配置信息
[[email protected] ~]# cat /proc/net/bonding/bond0
//关闭eth0网卡, 测试bond0是否正常
[[email protected] ~]# nmcli device disconnect eth0
系统 | 网卡 | bond地址 | bond模式 | bond功能 |
---|---|---|---|---|
Centos6.5 | eth0: | 172.16.12.128 | 172.16.12.250 | 模式0 |
eth1: 172.16.12.129 |
//1.创建绑定网卡配置文件
[[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
BONDING_OPTS=“mode=0 miimon=50” //如果使用模式1将mode修改为1即可
//2.修改eth0和eth1网卡配置文件
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
//3.添加驱动支持bond0
[[email protected] ~]# vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
centos/rhce7使用teaming实现聚合链路,能够提供网卡绑定之后的网络吞吐性能,并且提供网卡的故障切换处理能力。
Team是基于一个小型内核驱动实现聚合链路,在用户层提供teamd命令实现链路管理。
teamd可以实现以下模式的聚合链路
broadcast 广播容错
roundrobin 负载轮询:轮询调度,一个一个的来。
activebackup 主备(必考)
loadbalance 负载均衡:提高性能,提高吞吐量,性能高的跑的多,性能低的跑的少。
lacp 需要交换机支持lacp协议
//请使用命令行配置,图形界面配置不稳定
[[email protected] ~]# nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:“activebackup”}}’ ipv4.addresses 172.16.12.250/24 ipv4.gateway 172.16.12.2 ipv4.dns 172.16.12.2 ipv4.method manual
Connection ‘team0’ (cd90d0ee-b65e-488c-8fd2-85facb1d6868) successfully added.
//添加物理网卡连接至team0
[[email protected] ~]# nmcli connection add type team-slave con-name team0-port1 ifname eth1 master team0
Connection ‘team-slave0’ (34873b23-60ff-42cf-bf65-77479bcd7369) successfully added.
[[email protected] ~]# nmcli connection add type team-slave con-name team0-port2 ifname eth2 master team0
Connection ‘team-slave1’ (3cfc524f-cbf8-4039-b511-830b90a23726) successfully added.
//检查team0状态
[[email protected] ~]# ping -I team0 172.16.12.128
[[email protected] ~]# teamdctl team0 state
//断掉后检测
[[email protected] ~]# nmcli dev disconnect eth1
[[email protected] ~]# teamdctl team0 state
动态修改team模式
// 导出配置进行修改 (man teamd.conf)
[[email protected] ~]# teamdctl team0 config dump > /tmp/team.conf
[[email protected] ~]# vim /tmp/team.conf
//以最新修改的配置选项修改team0属性
[[email protected] ~]# nmcli con mod team0 team.config /tmp/team.conf
//修改之后需要重启team0
[[email protected] ~]# nmcli connection down team0;nmcli connection up team0
[[email protected] ~]# nmcli connection up team0-port1
[[email protected] ~]# nmcli connection up team0-port2
第一步,导出team的配置,(过程截图如下)
第二步,然后修改配置文件的模式。
第三步,然后将配置文件导入team网卡配置,
第四步,然后重启team网卡设备(一定要重启,否则设备不生效),最后查看设备信息。