網路群組team:是將多個網路卡聚合在一起,從而實現容錯和提高吞吐量
#1 建立網路群組介面
nmcli connection add type team con-name TEAMname ifname INTname [config JSON]
TEAMname 指定連接名,INname指定介面名,
JSON指定runner方式,格式為:'{" runner":{"name":"METHOD"}}'
METHOD 可以是broadcast、roundrobin、activebackup、loadbalance、lacp
(1)建立網路介面群組team0
[root@centos7 ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"loadbalance"}}'
Connection 'team0' (e70483a1 -2688-4eb2-9466-8e732360291d) successfully added.
(2)給網路組team0配置IP位址
[root@centos7 ~]# nmcli connection modify metham0
##[root@centos7 ~]# nmcli connection modify metham0 ipv4.methamodman ipv4.addresses 200.200.200.200/24 gw4 200.200.200.12 建立port介面(SLAVE)
既就是產生群組組成員的設定檔。 注意:這個設定檔和網卡設定檔是相互獨立的。 nmcli connection add type team-slave con-name SLAVEname ifname INname master TEAMnameSLAVEname 指定連線名,INTname指定網路介面名稱(相當於指定要加入網路群組的網路卡名), TEAMnmae指定所屬網路群組。 若連接名稱不指定,預設為team-slave-IFACE建立介面群組
這裡使用ens34、ens38兩塊網路卡[root@centos7 ~]# nmcli connection add con-name team0-ens34 type team-slave ifname ens34 master team0#Connection 'team0-ens34' (a481fb6d-bf61-413d-a27-ens34' (a481fb6d-bf61-413d-a27-28721a ) successfully added.[root@centos7 ~]# nmcli connection add con-name team0-ens38 type team-slave ifname ens38 master team0Connection 'team0-ens38' (758d0e-162 -46b2-b539-1d853a45be6b) successfully added.##3 啟用網路群組
啟用網路群組:nmcli connection up team0
## 啟用網路群組:nmcli connection up team0 啟用網路群組:nmcli connection up team0 啟用網路群組:nmcli connection up team0啟用群組成員:nmcli connection up SLAVEname[root@centos7 ~]# nmcli connection up team0Connection successfully activated (master waiting for slaves) (D-Bus active path: / org/freedesktop/NetworkManager/ActiveConnection/20)[root@centos7 ~]# nmcli connection up team0-ens34
Connection successfully activated (D-Bus active path: /org/freedesktop/ NetworkManager/ActiveConnection/23)[root@centos7 ~]# nmcli connection up team0-ens38Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/ 24) 4 查看網路群組狀態 teamdctl TEAMname state[root@centos7 ~]# teamdctl team0 state setup:runner: loadbalanceports:ens34link watches:#link summary: upinstance[link_watch_0]:name: ethtoollink: updown count: 0#ens38link watches:
link summary: upinstance[link_watch_0]:
name: ethtoollink: up
down count: 0 5 網路群組設定檔#(1)MASTER設定檔
[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-team0DEVICE=team0TEAM_CONFIG="{\"runner\":{\" name\":\"loadbalance\"}}"BOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noNAME=team0#UUID=e70483a1-2688-4eb2-9466-8e732360291d
ONBOOT=yes
DEVICETYPE=Team#IPADDR=200.200.200.20# PREFIX=24GATEWAY=200.200.200.1(2)群組成員(SLAVE)設定檔
#[root@centos7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-team0-ens34NAME=team0-ens34UUID=a4811a6d-bf61-413d-a2c7-289966bee1a76d-bf61-413d-a2c7-289966bee1a76d-bf61-413d-a2c7-289966bee1a77#DEVfb> ens34ONBOOT=yesTEAM_MASTER=team0
DEVICETYPE=TeamPort
6 刪除網路群組
#(1)斷開連接[root@centos7 ~]# nmcli connection down team0
Connection 'team0' successfully deactivated (D- Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
查看下狀態
#[root@centos7 ~]# teamdctl team0 state
Device "team0" does not exist
[root@centos7 ~]# nmcli connection show
NAME UUID TYPE DEVICE
###ens33 be9d1f2f-20e0-4282-9cb5-0da4c8b0-7c ens33######virbr0 8b1532d4-d99b-4201-8163-44d733302230 bridge virbr0######team0 e70483a1-2688-4eb2-######team0 e70483a1-2688-4eb2-9466-8e0 e70483a1-2688-4eb2-9466-8e73236213232#a#amd d-bf61 -413d-a2c7-289966bee1a7 802-3-ethernet --###team0-ens38 758d0eba-1625-46b2-b539-1d853a45be6b 802-3-ethernet --
可以看到已經關閉成功
(2)刪除TEAM群組成員
[root@centos7 ~]# nmcli connection delete team0-ens34
Connection 'team0-ens34' (a4816d-bf61-413d-a2c7-289966bee1a7) successffbleted.
#[root@centos7 ~]# nmcli connection delete team0-ens38Connection 'team0-ens38' (758d0eba-1625-46b2-b539-1d853a45be6b) successfully##ed.##家家. ##(3)刪除TEAM群組
[root@centos7 ~]# nmcli connection delete team0Connection 'team0' (e70483a1-2688-4eb2-9466-8e732360291d) successfully deleted.檢視[root@centos7 ~]# nmcli connection showNAME UUID TYPE DEVICEens33 be9d1f2f-20e0-4282-9cb5 -0da4c8b0fc7c 802-3-ethernet ens33virbr0 8b1532d4-d99b-4201-8163-44d733302230 bridge virbr0已經看不到team0 相關的內容,說明刪除成功###以上是網路組實現的步驟詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!