注:此试验主要介绍'activebackup' 网卡热备份模式
1、创建虚拟网卡组
命令:nmcli connection add type team
con-name team0 ifname team0
autoconnect yes
config '{"runner": {"name": "activebackup"}}'
命令格式简单说明:nmcli connection 添加 类型为 team(组队)
配置文件名 team0 网卡名 team0
每次开机自动启用
工作模式为 热备份
可以使用man命令辅助:man teamd.conf
# man teamd.conf #man帮助
EXAMPLES
{
"device": "team0",
"runner": {"name": "roundrobin"},
"ports": {"eth1": {}, "eth2": {}}
}
Very basic configuration.
{
"device": "team0",
"runner": {"name": "activebackup"},
"link_watch": {"name": "ethtool"},
# nmcli connection add type team con-name team0 ifname team0 autoconnect yes config '{"runner": {"name": "activebackup"}}'
Connection 'team0' (e29ceff9-4944-4a2f-b5db-f52bbb5c0263) successfully added.
# ifconfig team0 ###创建成功后查看
team0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether c6:8c:c4:9b:c6:1f txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2.给组里添加成员
命令:#nmcli connection add type team-slave
con-name team0-2 ifname eth2 master team0
命令简介:# nmcli connection 添加 类型 team-成员
配置文件名为 team0-2 网卡名 eth2 主设备 为team0
# nmcli connection add type team-slave con-name team0-1 ifname eth0 master team0
Connection 'team0-1' (bf3afedf-0b07-488c-9215-29159b0b5f3a) successfully added.
########添加网卡eth0到team0
# nmcli connection add type team-slave con-name team0-2 ifname eth1 master team0
Connection 'team0-2' (068fe4ac-8463-4033-b82d-de0916b74103) successfully added.
########添加网卡eth1到team0
3. 为虚拟网卡team0配置IP地址
# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.1.1/24 connection.autoconnect yes
4.激活配置
[root@server0 ~]# nmcli connection up team0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
# nmcli connection up team0-1
# nmcli connection up team0-2
5.测试效果
查看链路聚合状态的命令
# ifconfig eth0 down 如果网卡1down掉
# teamdctl team0 state 查看但前team0的状态
6.其他
#nmcli connection delete team0 #删除team0配置