網絡組相關實驗
阿新 • • 發佈:2019-04-02
dde idg bus oot move bond set obi 網卡 網絡組相關實驗
網絡組是centos7上新出的一個技術,它的作用和bonding類似,是將多個網卡聚合在一起方法,從而實現冗錯和提高吞吐量,不同於舊版中bonding技術,網路組提供更好的性能和擴展性,它是由內核驅動和teamd守護進程實現。
網路組可以工作在多種方式(runner)
broadcast
roundrobin
activebackup
loadbalance
lacp (implements the 802.3ad Link Aggregation Control Protocol)
實驗環境:
一臺CentOS7主機,網卡2塊。
創建網絡組
1.創建網路網
[[email protected] ~]# nmcli connection add con-name team0 ifname team0 type team ipv4.method manual ipv4.addresses 192.168.172.100 config ‘{"runner":{"name":"loadbalance"}}‘
Connection ‘team0‘ (24db0099-b9fa-4aae-ace0-9421e3c69278) successfully added.
2.添加物理網卡
分別將ens33和ens37添加至網路組內
[[email protected] ~]# nmcli connection add con-name team0-ens33 ifname ens33 type team-slave master team0 Connection ‘team0-ens33‘ (0d00650a-e379-4c70-9f62-ba268af1a208) successfully added. [[email protected] ~]# nmcli connection add con-name team0-ens37 ifname ens37 type team-slave master team0 Connection ‘team0-ens37‘ (2916ab1f-2e3c-477b-aaaf-52dfaecaaeb7) successfully added.
3.將物理網卡和網絡組關聯起來
#由於剛才只是將物理網卡添加至網絡組內,所以此時team0-ens33和team0-ens37並未啟用 [[email protected] ~]# nmcli connection NAME UUID TYPE DEVICE ens33 fca2f13f-7310-4595-bbb1-e6d0e3662aff ethernet ens33 team0 24db0099-b9fa-4aae-ace0-9421e3c69278 team team0 virbr0 803d85ba-4e80-470f-bcf5-1b22b5653026 bridge virbr0 Wired connection 1 3f019cd5-7685-3368-960c-101e35cd6ce7 ethernet ens37 team0-ens33 0d00650a-e379-4c70-9f62-ba268af1a208 ethernet -- team0-ens37 2916ab1f-2e3c-477b-aaaf-52dfaecaaeb7 ethernet -- #將網絡組內的物理網卡關聯起來 [[email protected] ~]# nmcli connection up team0-ens33 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7) [[email protected] ~]# nmcli connection up team0-ens37 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8) #此時team-ens33和team-ens37都已經啟用,網絡組創建成功 [[email protected] ~]# nmcli connection NAME UUID TYPE DEVICE team0 24db0099-b9fa-4aae-ace0-9421e3c69278 team team0 team0-ens33 0d00650a-e379-4c70-9f62-ba268af1a208 ethernet ens33 team0-ens37 2916ab1f-2e3c-477b-aaaf-52dfaecaaeb7 ethernet ens37 virbr0 803d85ba-4e80-470f-bcf5-1b22b5653026 bridge virbr0 ens33 fca2f13f-7310-4595-bbb1-e6d0e3662aff ethernet -- Wired connection 1 3f019cd5-7685-3368-960c-101e35cd6ce7 ethernet --
4.查看網絡組狀態
[[email protected] ~]# teamdctl team0 state
setup:
runner: loadbalance
ports:
ens33
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens37
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
網絡組的刪除
1.刪除相關配置文件
由於nmcli命令在執行時會自動生成網卡的配置文件,所以刪除網路組時需要將相應的配置文件進行刪除
[[email protected] ~]# rm -vf /etc/sysconfig/network-scripts/ifcfg-team0*
removed ‘/etc/sysconfig/network-scripts/ifcfg-team0’
removed ‘/etc/sysconfig/network-scripts/ifcfg-team0-ens33’
removed ‘/etc/sysconfig/network-scripts/ifcfg-team0-ens37’
2.取消相關網卡的關聯
#將網絡組中的ens33及ens37取消關聯
[[email protected] ~]# nmcli connection down team0-ens33
Connection ‘team0-ens33‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[[email protected] ~]# nmcli connection down team0-ens37
Connection ‘team0-ens37‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
#刪除鏈接ens33和ens37
[[email protected] ~]# nmcli connection delete team0-ens33
Connection ‘team0-ens33‘ (0d00650a-e379-4c70-9f62-ba268af1a208) successfully deleted.
[[email protected] ~]# nmcli connection delete team0-ens37
Connection ‘team0-ens37‘ (2916ab1f-2e3c-477b-aaaf-52dfaecaaeb7) successfully deleted.
3.將網路組刪除
#先禁用網路組
[[email protected] ~]# nmcli connection down team0
Connection ‘team0‘ successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
#將網路組刪除
[[email protected] ~]# nmcli connection delete team0
Connection ‘team0‘ (24db0099-b9fa-4aae-ace0-9421e3c69278) successfully deleted.
此時網路組已經從主機上刪除
[[email protected] ~]# nmcli connection
NAME UUID TYPE DEVICE
ens33 fca2f13f-7310-4595-bbb1-e6d0e3662aff ethernet ens33
virbr0 803d85ba-4e80-470f-bcf5-1b22b5653026 bridge virbr0
Wired connection 1 3f019cd5-7685-3368-960c-101e35cd6ce7 ethernet ens37
網絡組相關實驗