首頁 > 軟體

CentOS 7.2 雙網絡卡系結及相關問題解決

2020-06-16 17:05:25

線上伺服器,安裝CentOS 7.2 x64最小化安裝,需要做鏈路聚合,雙網絡卡系結。在CentOS 6.x 和 CentOS 7上測試都OK,於是直接開搞。

  說明下,以下環境是在虛擬機器中實現的:

  系統: CentOS 7.2 x64 最小化安裝。

為了方便演示,這裡共有三張網絡卡:
   eno16777736 : 橋接網絡卡:10.0.0.11/24
   剩下的兩張網絡卡準備做系結:
       eno33554984
       eno50332208

[root@linuxidc ~]# nmcli con sh 
NAME                UUID                                  TYPE            DEVICE      
Wired connection 2  bf0cf9b6-c7fb-4c0a-ada4-abfb650dd5f0  802-3-ethernet  --          
Wired connection 1  5b4e0b3e-c469-404c-8839-76d18442fc20  802-3-ethernet  --          
eno16777736         100e462e-c0d0-4271-9b5a-1c8e47ff0d03  802-3-ethernet  eno16777736 
[root@linuxidc ~]# nmcli con del 5b4e0b3e-c469-404c-8839-76d18442fc20 bf0cf9b6-c7fb-4c0a-ada4-abfb650dd5f0
Connection 'Wired connection 1' (5b4e0b3e-c469-404c-8839-76d18442fc20) successfully deleted.
Connection 'Wired connection 2' (bf0cf9b6-c7fb-4c0a-ada4-abfb650dd5f0) successfully deleted.

[root@linuxidc ~]# nmcli con add type team ifname team0 con-name team0 config '{"runner":{"name":"roundrobin"}}'
Connection 'team0' (913f05c2-15d8-49a9-a35f-8bc5ee843c0c) successfully added.
[root@linuxidc ~]# nmcli con add type team-slave ifname eno50332208 con-name team0-port2 master team0
Connection 'team0-port2' (1583854c-1f85-4c76-8cc7-c643071d4b82) successfully added.
[root@linuxidc ~]# nmcli con mod team0 ipv4.address "192.168.121.100/24"
[root@linuxidc ~]# nmcli con mod team0 ipv4.method manual

[root@linuxidc ~]# nmcli con sh 
NAME         UUID                                  TYPE            DEVICE      
eno16777736  100e462e-c0d0-4271-9b5a-1c8e47ff0d03  802-3-ethernet  eno16777736 
team0-port2  1583854c-1f85-4c76-8cc7-c643071d4b82  802-3-ethernet  --          
team0-port1  bfd408b4-76d9-4f5c-ad5b-4d92430eb6ba  802-3-ethernet  --          
team0        913f05c2-15d8-49a9-a35f-8bc5ee843c0c  team            --  

到這裡都沒毛病。

[root@linuxidc ~]# nmcli con up team0
Error: Connection activation failed: NetworkManager plugin for 'team' unavailable

什麼鬼?NetworkManager "team"外掛不可用。於是開始排查。

是否存在team模組

[root@linuxidc ~]# lsmod | egrep *team*

木有。那直接restart network好了。

[root@linuxidc ~]# systemctl restart network 
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

[root@linuxidc ~]# systemctl status network
...
Mar 25 04:47:56 linuxidc network[2742]: Bringing up interface team0:  Error: Connection activation failed: NetworkManager plugin for 'team' unavailable
Mar 25 04:47:56 linuxidc network[2742]: [FAILED]
...

一樣的報錯,難道什麼包沒有安裝到?

[root@linuxidc ~]# yum list all | grep NetworkManager*
NetworkManager.x86_64                   1:1.0.6-27.el7                 @anaconda
NetworkManager-libnm.x86_64             1:1.0.6-27.el7                 @anaconda
NetworkManager-tui.x86_64               1:1.0.6-27.el7                 @anaconda
NetworkManager-wifi.x86_64              1:1.0.6-27.el7                 @anaconda
NetworkManager-adsl.x86_64              1:1.0.6-27.el7                 yum      
NetworkManager-bluetooth.x86_64         1:1.0.6-27.el7                 yum      
NetworkManager-glib.x86_64              1:1.0.6-27.el7                 yum      
NetworkManager-libreswan.x86_64         1.0.6-3.el7                    yum      
NetworkManager-libreswan-gnome.x86_64   1.0.6-3.el7                    yum      
NetworkManager-team.x86_64              1:1.0.6-27.el7                 yum      
NetworkManager-wwan.x86_64              1:1.0.6-27.el7                 yum 

哎喲,還真有個NetworkManager-team沒有安裝叻。

[root@linuxidc ~]# yum install NetworkManager-team -y

然後再次嘗試:

[root@linuxidc ~]# nmcli con sh 
NAME         UUID                                  TYPE            DEVICE      
eno16777736  100e462e-c0d0-4271-9b5a-1c8e47ff0d03  802-3-ethernet  eno16777736 
team0-port2  1583854c-1f85-4c76-8cc7-c643071d4b82  802-3-ethernet  --          
team0-port1  bfd408b4-76d9-4f5c-ad5b-4d92430eb6ba  802-3-ethernet  --          
team0        913f05c2-15d8-49a9-a35f-8bc5ee843c0c  team            -- 

[root@linuxidc ~]# nmcli con up team0
Error: Connection activation failed: NetworkManager plugin for 'team' unavailable

尼瑪,還是同樣的錯,這就尷尬了。那就重新啟動下NetworkManager 在看看。

[root@linuxidc ~]# systemctl restart NetworkManager

[root@linuxidc ~]# nmcli con sh 
NAME         UUID                                  TYPE            DEVICE      
team0-port2  1583854c-1f85-4c76-8cc7-c643071d4b82  802-3-ethernet  eno50332208 
eno16777736  100e462e-c0d0-4271-9b5a-1c8e47ff0d03  802-3-ethernet  eno16777736 
team0-port1  bfd408b4-76d9-4f5c-ad5b-4d92430eb6ba  802-3-ethernet  eno33554984 
team0        913f05c2-15d8-49a9-a35f-8bc5ee843c0c  team            team0

好了? 緊檢視是不是roundrobin模式

[root@linuxidc ~]# teamdctl team0 st
setup:
  runner: roundrobin
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
[root@linuxidc ~]# teamnl team0 ports 
 4: eno50332208: up 1000Mbit FD 
 3: eno33554984: up 1000Mbit FD

一切OK,老鐵,紮心了。

接下來測試下roundrobin
   這裡說明下:roundrobin這種bind模式:
       先來講下網絡卡bind的原理:
           通過將兩張或者多張網絡卡通過軟體虛擬出來一張邏輯網絡卡來傳輸資料,這裡bind的模式有很多種。比如我們上面的這種,就是其中的鏈路聚合模式。當使用該模式的時候,兩張物理網絡卡和邏輯網絡卡的mac地址都被設定為一致,大家都知道,我們做鏈路聚合就是為了讓多張物理網絡卡聚合在一塊擴充套件資料頻寬的方式,既然我們在邏輯上是一張網絡卡,那mac地址也就必須一致對吧。不然我們接到交換機或者路由器上,邏輯網絡卡一會是物理網絡卡1的mac地址,一會又是物理網絡卡2的地址,交換機一會找的到人,一會又找不到人。那資料還怎麼傳輸。

           在鏈路聚合中,因為是兩張物理網絡卡綑綁的模式,如果其中一張網絡卡down掉了,整個鏈路也就癱了。

    如下:

本文永久更新連結地址http://www.linuxidc.com/Linux/2017-10/147348.htm


IT145.com E-mail:sddin#qq.com