Team 是 RHEL 7 引進的網路聚合方案,由一個名為 teamd 的 user-space 守護程序負責,好處是擴充性佳、可透過 JSON 描述任意 runner 行為。若要在 team 之上再疊 VLAN,請參考「在 RHEL 7 以 NetworkManager 為 team 設定 VLAN」一文。
環境:Red Hat Enterprise Linux 7、NetworkManager、teamd。
下列指令會建立一支名為 myteam 的連線 profile,對應的裝置名稱為 team0,runner 採 activebackup,並使用 ethtool 做鏈路監控:
### 靜態 IP:
# nmcli connection add type team con-name myteam ifname team0 config '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' ip4 192.168.0.100/24 gw4 192.168.0.1
### DHCP:
# nmcli connection add type team con-name myteam ifname team0 config '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'
這裡有個很多人踩過的細節:master 參數要填 team 的裝置名稱,不是 profile 名稱。以下把 ens10 與 ens15 加入 team0:
# nmcli connection add type team-slave con-name myteam-port1 ifname ens10 master team0 # nmcli connection add type team-slave con-name myteam-port2 ifname ens15 master team0
至少要確認使用的 runner 正確,否則可能看起來「有設定」卻完全不通:
# teamdctl team0 state
setup:
runner: activebackup
ports: ens10 ens15
ens10
link watches:
link summary: up
instance[link_watch_0]: name=ethtool link=up down count=0
ens15
link watches:
link summary: up
instance[link_watch_0]: name=ethtool link=up down count=0
runner: active
port: ens10
這些屬性可以在 profile 建立後再設定。先看有哪些可用屬性,再逐一修改:
# nmcli connection show <profile name> # nmcli connection modify <profile name> <property> <value>
所有屬性與其可接受值,都在 nm-settings man page 中有完整說明。
建議先停用或刪除即將被納入 team 的實體網卡上既有的連線 profile,確保永遠是正確的 profile 被啟用。下面的指令會列出所有 profile 的 connection.id 與對應介面:
# for connection in $(nmcli -t --fields uuid con) ; do echo ; nmcli con show uuid $connection | egrep "connection.id|connection.interface-name" ; done
若確認要移除,用 profile 的 connection.id 刪除即可(也可以改把 connection.autoconnect 設為 no,但記下名稱以免日後誤用):
# nmcli connection del "$PROFILE"
更多關於 teaming 的 runner 類型與設定選項,可參考 RHEL 7 網路指南中的「Configure Network Teaming」章節,以及 teamd.conf man page。挑 runner 的原則很簡單:只是要備援就選 activebackup;要頻寬合併且對端是支援 LACP 的交換器,才考慮 loadbalance 或 802.3ad。
本文整理自 TechArticle 技術文章。