配置team高可用
查看本地网卡情况
[root@www ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
ens224 ethernet connected Wired connection 1
ens256 ethernet connected Wired connection 2
virbr0 bridge connected (externally) virbr0
查看示例文件
[root@www ~]# cd /usr/share/doc/teamd/example_configs/
[root@www example_configs]# ll
total 64
-rw-r--r--. 1 root root 305 Jul 26 2020 activebackup_arp_ping_1.conf
……
选择链路聚合配置模型
[root@www example_configs]# vim activebackup_arp_ping_1.conf
取用以下内容
"runner": {"name": "activebackup"}
创建team0设备和team0会话
[root@www example_configs]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"} }'
Connection 'team0' (feef60b6-274d-4414-8acc-cb8e5fb8eb4b) successfully added.
查看创建好的team0会话
[root@www example_configs]# nmcli connection show
NAME UUID TYPE DEVICE
team0 b3c03004-0ab7-4be2-a489-108b33b50233 team team
ens160 fc9ae3a1-1fde-48ce-a728-2822b2c98a70 ethernet ens160
Wired connection 1 919c4f5c-5b93-3f89-bf35-6d8f8999721d ethernet ens224
Wired connection 2 8bfac97f-25a5-3818-a074-1c1a9c47d51e ethernet ens256
virbr0 c24dc552-0fe2-4f9a-ae18-3cc4cc76accd bridge virbr0
添加设备到team0
[root@www example_configs]# nmcli connection add type team-slave con-name team0-port1 ifname ens224 master team0
Connection 'team0-port1' (baeb82ec-1c6d-4ee0-88b3-460d21f8b123) successfully added.
* nmcli connection add type team-slave con-name team0-port1 ifname ens224 master team0
类型:子接口 会话名称:子接口的端口 选择网口:ens224 子接口及子接口 对应的会话添加到team0设备
[root@www example_configs]# nmcli connection add type team-slave con-name team0-port2 ifname ens256 master team0
Connection 'team0-port2' (8c37948e-2aad-4683-844b-bc3dab1cbffd) successfully added.
修改team0会话的IP地址
[root@www example_configs]# nmcli connection modify team0 ipv4.addresses 192.168.19.200/24
更改IP地址获取方式为手动
[root@www example_configs]# nmcli connection modify team0 ipv4.method manual
#更改IP地址获取方式为自动
[root@localhost ~]# nmcli connection modify team0 ipv4.method auto
启动子接口(从设备激活)
[root@www example_configs]# nmcli connection up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[root@www example_configs]# nmcli connection up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)
激活主设备
[root@www example_configs]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)
然后就可以连接 192.168.19.200
测试
[root@www ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens224
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens256
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens224
常ping: [C:\~]$ ping 192.168.19.200 -t
停用一个从设备会话来检验效果
[root@www ~]# nmcli connection down team0-port1
#停用一个从设备真实网卡来检验效果
[root@localhost ~]# nmcli device disconnect ens224
删除
[root@www ~]# nmcli connection delete team0-port1
Connection 'team0-port1' (112bdbe7-56f1-4a0c-803f-4f2000b26ab1) successfully deleted.
[root@www ~]# nmcli connection delete team0-port2
Connection 'team0-port2' (8c37948e-2aad-4683-844b-bc3dab1cbffd) successfully deleted.
[root@www ~]# nmcli connection delete team0
Connection 'team0' (b3c03004-0ab7-4be2-a489-108b33b50233) successfully deleted.
[root@www example_configs]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 fc9ae3a1-1fde-48ce-a728-2822b2c98a70 ethernet ens160
Wired connection 1 919c4f5c-5b93-3f89-bf35-6d8f8999721d ethernet ens224
Wired connection 2 8bfac97f-25a5-3818-a074-1c1a9c47d51e ethernet ens256
virbr0 036b1e24-3d72-4532-93d0-308617406dee bridge virbr0