一、系統環境
1、在VMware Workstation部署Centos7系統
2、新增網絡卡
3、檢視網絡卡,看到新加的兩張網絡卡(eno33554984,eno50332208)是沒有IP地址的
[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:10:c4:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.253.131/24 brd 192.168.253.255 scope global dynamic eno16777736
valid_lft 1601sec preferred_lft 1601sec
inet6 fe80::20c:29ff:fe10:c416/64 scope link
valid_lft forever preferred_lft forever
3: eno33554984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:10:c4:20 brd ff:ff:ff:ff:ff:ff
4: eno50332208: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:10:c4:2a brd ff:ff:ff:ff:ff:ff
二、設定過程
1、nmcli檢視裝置狀態,新增的網絡卡CONNECTION爲Wired connection 2和1狀態
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
eno33554984 ethernet connected Wired connection 2
eno50332208 ethernet connected Wired connection 1
lo loopback unmanaged –
如果CONNECTION顯示:Wired connection,刪除即可
[root@localhost ~]# nmcli connection delete Wired\ connection\ 2
Connection ‘Wired connection 2’ (53ae8d3b-0774-42bb-949c-ae01a7fb22b8) successfully deleted.
[root@localhost ~]# nmcli connection delete Wired\ connection\ 1
Connection ‘Wired connection 1’ (25511265-8a01-4a1c-a370-14091516243b) successfully deleted.
2、建立鏈接聚合team1並檢視網絡卡狀態
[root@localhost ~]# nmcli connection add type team con-name team1 ifname team1 config ‘{「runner」:{「name」:「activebackup」}}’
Connection ‘team1’ (11162383-33d9-4b86-9cee-1349c9c273f7) successfully added.
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
team1 team connecting (getting IP configuration) team1
eno33554984 ethernet disconnected –
eno50332208 ethernet disconnected –
lo loopback unmanaged –
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
eno16777736 2a18182f-7e85-40bf-93bc-c28fe4564ba3 802-3-ethernet eno16777736
team1 11162383-33d9-4b86-9cee-1349c9c273f7 team team1
3、將兩張新網絡卡新增到這個team1中並檢視網絡卡狀態
[root@localhost ~]# nmcli connection add type team-slave con-name eno33554984 ifname eno33554984 master team1
Connection ‘eno33554984’ (722991e8-a542-4761-b347-334d13cae25a) successfully added.
[root@localhost ~]#
[root@localhost ~]# nmcli connection add type team-slave con-name eno50332208 ifname eno50332208 master team1
Connection ‘eno50332208’ (154fdde2-f162-47d5-b2d4-11dd89ae3a0f) successfully added.
[root@localhost ~]# nmcli device status
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno16777736
eno33554984 ethernet connected eno33554984
eno50332208 ethernet connected eno50332208
team1 team connected team1
lo loopback unmanaged –
[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
eno16777736 2a18182f-7e85-40bf-93bc-c28fe4564ba3 802-3-ethernet eno16777736
eno50332208 154fdde2-f162-47d5-b2d4-11dd89ae3a0f 802-3-ethernet eno50332208
eno33554984 722991e8-a542-4761-b347-334d13cae25a 802-3-ethernet eno33554984
team1 11162383-33d9-4b86-9cee-1349c9c273f7 team team1
4、設定team1的IP地址,紅色框是需要修改和新增的內容
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-team1
5、重新啓動網絡卡服務
[root@localhost ~]# systemctl restart network
檢視到網絡卡狀態都是OK
[root@localhost ~]# systemctl status network
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: active (exited) since Mon 2018-07-09 18:29:13 CST; 21s ago
Docs: man:systemd-sysv-generator(8)
Process: 3353 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS)
Process: 3657 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)
Jul 09 18:29:13 localhost.localdomain network[3657]: Could not load file ‘/etc/sysconfig/network-scripts/ifcfg-lo’
Jul 09 18:29:13 localhost.localdomain network[3657]: [ OK ]
Jul 09 18:29:13 localhost.localdomain network[3657]: Bringing up interface eno16777736: Connection successfully activated (D-Bus active pat…tion/6)
Jul 09 18:29:13 localhost.localdomain network[3657]: [ OK ]
Jul 09 18:29:13 localhost.localdomain network[3657]: Bringing up interface eno33554984: Connection successfully activated (D-Bus active pat…tion/7)
Jul 09 18:29:13 localhost.localdomain network[3657]: [ OK ]
Jul 09 18:29:13 localhost.localdomain network[3657]: Bringing up interface eno50332208: Connection successfully activated (D-Bus active pat…tion/9)
Jul 09 18:29:13 localhost.localdomain network[3657]: [ OK ]
Jul 09 18:29:13 localhost.localdomain network[3657]: Bringing up interface team1: [ OK ]
Jul 09 18:29:13 localhost.localdomain systemd[1]: Started LSB: Bring up/down networking.
Hint: Some lines were ellipsized, use -l to show in full.
6、檢視team1的IP地址和聚合設定,可以看到eno33554984是當前主介面
[root@localhost ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:10:c4:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.253.131/24 brd 192.168.253.255 scope global dynamic eno16777736
valid_lft 1727sec preferred_lft 1727sec
inet6 fe80::20c:29ff:fe10:c416/64 scope link
valid_lft forever preferred_lft forever
3: eno33554984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team1 state UP qlen 1000
link/ether 00:0c:29:10:c4:20 brd ff:ff:ff:ff:ff:ff
4: eno50332208: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team1 state UP qlen 1000
link/ether 00:0c:29:10:c4:20 brd ff:ff:ff:ff:ff:ff
6: team1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:10:c4:20 brd ff:ff:ff:ff:ff:ff
inet 192.168.253.140/24 brd 192.168.253.255 scope global team1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe10:c420/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]# teamdctl team1 state
setup:
runner: activebackup
ports:
eno33554984
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eno50332208
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno33554984
7、模擬介面故障,關掉一個介面測試,主介面變爲eno50332208
[root@localhost ~]# ifdown eno33554984
Device ‘eno33554984’ successfully disconnected.
[root@localhost ~]# teamdctl team1 state
setup:
runner: activebackup
ports:
eno50332208
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno50332208
8、當故障介面恢復也不會搶佔主介面,從而避免網路抖動
[root@localhost ~]# ifup eno33554984
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/10)
[root@localhost ~]# teamdctl team1 state
setup:
runner: activebackup
ports:
eno33554984
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eno50332208
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno50332208