Linux系统之Team链路聚合配置
@TOC
一、Team链路聚合介绍
1. Teaming技术简介
1.Teaming技术就是把同一台服务器上的多个物理网卡通过软件绑定成一个虚拟网卡;
2.我们可以通过Teaming技术做链路聚合,实现不同网卡的网卡的负载均衡和冗余;
2. 网卡的bonding和Teaming技术
1.一般在在RHEL5/RHEL6中使用的是Bonding,而RHEL7提供了一项新的实现技术Teaming,用来实现链路聚合的功能。
2.网卡的链路聚合一般常用的有"bond"和"team"两种模式,"bond"模式最多可以添加两块网卡,"team"模式最多可以添加八块网卡。
3. Team常用工作模式
Team常用工作模式如下:
- roundrobin: 以轮循的模式传输所有端口的包
- activebakup:主备模式这是一个故障迁移程序,监控链接更改并选择活动的端口进行传输
- loadbalance: 监控流量并使用哈希函数以尝试在选择传输端口的时候达到完美均衡
- broadcast: 广播容错,设备通过所有端口传输数据包
二、实践环境规划
本次实践规划:
hostname | team接口IP地址 | 物理网卡 | 操作系统版本 |
---|---|---|---|
jeven | 192.168.200.126 | ens37/38/39/40 | centos 7.6 |
三、添加物理网卡
1. 新增物理网卡
给虚拟机新增四张物理网卡
需要注意的是添加的网络适配器需网络模式一致,添加的个数为2的指数。
2. 查看网卡信息
查看新增的4张网卡ens37/38/39/40,已正常添加。
[root@jeven ~]# ip add |grep ens
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.3.166/24 brd 192.168.3.255 scope global noprefixroute dynamic ens33
120: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.200.215/24 brd 192.168.200.255 scope global noprefixroute dynamic ens37
121: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.200.216/24 brd 192.168.200.255 scope global noprefixroute dynamic ens38
122: ens39: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.200.212/24 brd 192.168.200.255 scope global noprefixroute dynamic ens39
126: ens40: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.200.217/24 brd 192.168.200.255 scope global noprefixroute dynamic ens40
四、Team链路聚合配置
1. 查看team的工作模式
通过teamd.conf查看team的工作模式
man teamd.conf
2. 创建team0的网络接口
使用 nmcli 命令,添加一个 team 网络接口 team0,我们选择的team模式是activebakup主备模式。
[root@jeven ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'
Connection 'team0' (7d4367b3-4f6b-4fbf-968f-daf110d7292b) successfully added.
3. 配置team0接口的IP地址
配置team0接口的IP地址为192.168.200.126/24
mcli connection modify team0 ipv4.addresses 192.168.200.126/24 ipv4.method manual
4. 添加team0的子接口
将物理网卡ens37、ens38、ens39、ens40作为team0的子接口。
[root@jeven ~]# nmcli connection add type team-slave con-name team0-port1 ifname ens37 master team0
Connection 'team0-port1' (66450b15-fdec-48d8-9df4-ba8ab29c8633) successfully added.
[root@jeven ~]# nmcli connection add type team-slave con-name team0-port2 ifname ens38 master team0
Connection 'team0-port2' (dc869a3b-d9bd-49a7-a1b8-1368e5f2e0db) successfully added.
[root@jeven ~]# nmcli connection add type team-slave con-name team0-port3 ifname ens39 master team0
Connection 'team0-port3' (df21f75f-0343-45e7-9051-f3063cedfee0) successfully added.
[root@jeven ~]# nmcli connection add type team-slave con-name team0-port4 ifname ens40 master team0
Connection 'team0-port4' (58838a61-fb21-443f-a932-959ebd40c21e) successfully added.
5. 激活网卡
重启网络服务
[root@jeven network-scripts]# nmcli con reload
[root@jeven network-scripts]# nmcli con up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/38)
[root@jeven network-scripts]# nmcli con up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/39)
[root@jeven network-scripts]# nmcli con up team0-port3
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/40)
[root@jeven network-scripts]# nmcli con up team0-port4
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/41)
6. 检查team0接口的状态
检查team0接口的状态,当前活动的网卡为ens37。
[root@jeven network-scripts]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens39
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens40
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens37
五、测试Team链路聚合
1. 测试team0接口的网络连通情况
在宿主机,ping其team0的IP地址,网络正常。
ping 192.168.200.126 -t
1. 停用ens37网卡
在本机停用ens37网卡,在局域网其他主机测试其连通性。
- 本机停用ens37网卡
[root@jeven ~]# ifdown ens37
Device 'ens37' successfully disconnected.
- 查看当前team接口状态,可以看到现在ens40网卡接管服务。
[root@jeven ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens39
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens40
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens40
3. 测试网络情况
继续查看网络连通性,网络正常,网络没有中断。
六、删除子接口操作
1. 删除子接口
查看网卡连接信息
[root@jeven ~]# nmcli con show
NAME UUID TYPE DEVICE
docker0 85baca8e-d2b0-4fdc-bf5d-2d202ae7d2a3 bridge docker0
ens33 ba415981-963e-4130-984a-8dd764f4bb70 ethernet ens33
team0 7d4367b3-4f6b-4fbf-968f-daf110d7292b team team0
team0-port1 66450b15-fdec-48d8-9df4-ba8ab29c8633 ethernet ens37
team0-port2 dc869a3b-d9bd-49a7-a1b8-1368e5f2e0db ethernet ens38
team0-port3 df21f75f-0343-45e7-9051-f3063cedfee0 ethernet ens39
team0-port4 58838a61-fb21-443f-a932-959ebd40c21e ethernet ens40
virbr0 d83517b6-f9f1-434b-bf41-dcedb7cb1bde bridge virbr0
删除子接口
[root@jeven ~]# nmcli con delete team0-port4
Connection 'team0-port4' (58838a61-fb21-443f-a932-959ebd40c21e) successfully deleted.
[root@jeven ~]# nmcli con delete team0-port3
Connection 'team0-port3' (df21f75f-0343-45e7-9051-f3063cedfee0) successfully deleted.
2. 查看网卡信息
查看网卡连接信息
[root@jeven ~]# nmcli con show
NAME UUID TYPE DEVICE
docker0 85baca8e-d2b0-4fdc-bf5d-2d202ae7d2a3 bridge docker0
ens33 ba415981-963e-4130-984a-8dd764f4bb70 ethernet ens33
team0 7d4367b3-4f6b-4fbf-968f-daf110d7292b team team0
team0-port1 66450b15-fdec-48d8-9df4-ba8ab29c8633 ethernet ens37
team0-port2 dc869a3b-d9bd-49a7-a1b8-1368e5f2e0db ethernet ens38
virbr0 d83517b6-f9f1-434b-bf41-dcedb7cb1bde bridge virbr0
Wired connection 4 02e53166-ccb4-38cf-b922-a5ffd8c549e5 ethernet ens40
Wired connection 1 2650ffb4-2ebf-361f-b30f-489f12a7b889 ethernet --
Wired connection 2 412789b9-ffeb-3280-8129-8c4465f0a779 ethernet --
Wired connection 3 80a0f41d-942f-3e88-8d22-c63604519d15 ethernet --
查看team接口状态
[root@jeven ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens38
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens38
3. 重启team0
重启team0,查看当前网络连接状态,ens39/40两张网卡已停止使用。
[root@jeven network-scripts]# nmcli con reload
[root@jeven network-scripts]# nmcli con up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/52)
[root@jeven network-scripts]# nmcli con show
NAME UUID TYPE DEVICE
docker0 85baca8e-d2b0-4fdc-bf5d-2d202ae7d2a3 bridge docker0
ens33 ba415981-963e-4130-984a-8dd764f4bb70 ethernet ens33
team0 7d4367b3-4f6b-4fbf-968f-daf110d7292b team team0
team0-port1 66450b15-fdec-48d8-9df4-ba8ab29c8633 ethernet ens37
team0-port2 dc869a3b-d9bd-49a7-a1b8-1368e5f2e0db ethernet ens38
virbr0 d83517b6-f9f1-434b-bf41-dcedb7cb1bde bridge virbr0
Wired connection 1 2650ffb4-2ebf-361f-b30f-489f12a7b889 ethernet --
Wired connection 2 412789b9-ffeb-3280-8129-8c4465f0a779 ethernet --
Wired connection 3 80a0f41d-942f-3e88-8d22-c63604519d15 ethernet --
Wired connection 4 02e53166-ccb4-38cf-b922-a5ffd8c549e5 ethernet --
- 点赞
- 收藏
- 关注作者
评论(0)