next up previous contents
Next: 測試網路聚合 Up: Link Aggregation 網路聚合 Previous: 前言   Contents


建立網路聚合

  1. 多個網路連接埠整合成一個虛疑網路卡可增加原本單埠時的速度,使用 nmcli 語法:
    #nmcli con add type team con-name CNAME ifname INAME [config JSON]
    
  2. JSON (JavaScript Object Notation) 指定使用 runner,語法為:
    '{"runner":{"name":"METHOD"}}'
    
  3. METHOD 在 RHEL7/CentOS7 中支援的 Teaming 模式有 broadcast, activebackup, roundrubin, loadbalance 與 lacp 五種,細節可以參考 teamd.conf 手冊。
    [root@kvm7 ~]# man 5 teamd.conf
    
  4. 產生 team 介面卡之前,先查看目前主機有 eth0 eth1 eth2 三張網卡。
    [root@kvm5 ~]# nmcli device 
    DEVICE  TYPE      STATE         CONNECTION 
    eth0    ethernet  connected     eth0       
    eth1    ethernet  disconnected  --         
    eth2    ethernet  disconnected  --         
    lo      loopback  unmanaged     --
    
  5. 使用 activebackup 模式產生一個名為 team0 的網路 team 介面。
    [root@kvm5 ~]# nmcli connection add type team con-name team0 ifname team0 \
    config '{"runner": {"name": "activebackup"}}'
    Connection 'team0' (e1d07964-d037-4d1d-ae23-4a6d6430d82d) successfully added.
    
  6. 查看 device 或 connection,多了 team0 的網路 team 介面,其網路連線設定名稱也是 team0。
    [root@kvm5 ~]# nmcli device 
    DEVICE  TYPE      STATE                                  CONNECTION 
    eth0    ethernet  connected                              eth0       
    team0   team      connecting (getting IP configuration)  team0      
    eth1    ethernet  disconnected                           --         
    eth2    ethernet  disconnected                           --         
    lo      loopback  unmanaged                              --         
    [root@kvm5 ~]# nmcli connection 
    NAME   UUID                                  TYPE            DEVICE 
    team0  e1d07964-d037-4d1d-ae23-4a6d6430d82d  team            team0  
    eth0   657b29a2-b7c0-4176-a955-b12aadf9c156  802-3-ethernet  eth0
    
  7. 指定 eth1 及 eth2 為 team0 的網路埠。
    [root@kvm5 ~]# nmcli connection add type team-slave con-name \
    team0-port1 ifname eth1 master team0 
    Connection 'team0-port1' (e150c255-b7a2-47d8-977d-e1f429249aaf) 
    successfully added.
    [root@kvm5 ~]# nmcli connection add type team-slave con-name \
    team0-port2 ifname eth2 master team0 
    Connection 'team0-port2' (ebb32a20-01d3-4a36-8501-8fd02c5e9b20) 
    successfully added.
    
  8. 重啟網路。
    [root@kvm5 ~]# systemctl restart network.service
    
  9. 查看 team0 是不是包含 eth1 及 eth2 兩個成員埠。
    [root@kvm5 ~]# teamdctl team0 state
    setup:
      runner: activebackup
    ports:
      eth1
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
      eth2
        link watches:
          link summary: up
          instance[link_watch_0]:
            name: ethtool
            link: up
    runner:
      active port: eth1
    
  10. 設定 team0 綁定的 ip 192.168.122.15, netmask 255.255.255.0。因為要自行設定 IP, NETMASK 等參數,所以設定 team0 ipv4.method 為 manual,也就是手動,而不是 auto。
    [root@kvm5 ~]# nmcli connection modify team0 \
    ipv4.addresses 192.168.122.15/24 ipv4.method manual
    
  11. 啟動 team0。
    [root@kvm5 ~]# nmcli connection up team0
    Connection successfully activated (D-Bus active path: 
    /org/freedesktop/NetworkManager/ActiveConnection/119)
    
  12. 查看 team0 的 IP 為 192.168.122.15。
    [root@kvm5 ~]# ifconfig team0
    team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.122.15  netmask 255.255.255.0  broadcast 192.168.122.255
            inet6 fe80::5054:ff:fe00:51  prefixlen 64  scopeid 0x20<link>
            ether 52:54:00:00:00:51  txqueuelen 0  (Ethernet)
            RX packets 21  bytes 798 (798.0 B)
            RX errors 0  dropped 54  overruns 0  frame 0
            TX packets 33  bytes 5408 (5.2 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    



De-Yu Wang 2018-09-07