RHCE試題EX300詳解(五)配置鏈路聚合

題目要求:配置鏈路聚合

在 server0 和 desktop0 之間按以下要求配置鏈路聚合

  • l 此鏈路使用接口 eth1 和 eth2
  • l 此鏈路在一個接口失效後,仍然能工作
  • l 此鏈路在 server0 上使用地址 192.168.0.11/24
  • l 此鏈路在 desktop0 上使用地址 192.168.0.10/24
  • l 此鏈路在系統重啟後依然保持正常狀態

知識點小貼士:

Linux 鏈路聚合:鏈路聚合與雙網卡綁定幾乎相同,可以實現多網卡綁定主從榮譽,負載均衡,提高網絡訪問流量。但鏈路聚合與雙網卡綁定技術(bond)不同點就在於,雙網卡綁定只能使用兩個網卡綁定,而鏈路聚合最多可將8個網卡匯聚同時做綁定,此聚合模式稱之為team。默認情況下NetworkManager程序中集成了teamd功能就來配置鏈路聚合。

team 四種模式

  • 廣播容錯:"broadcast"
  • 平衡輪詢:"roundrobin"
  • 主備:"activebackup"
  • 負載均衡:"loadbalance"

解題步驟:

(1)首先在desktop0上查找可複製的幫助命令及參考例子:由於nmcli 下的命令都比較長,所以我們不用死記,新版裡的幫助和命令參數的tab補全特別好用,可以幫助我們搞定記不住的東西,通過man nmcli-examples查看和複製:

RHCE試題EX300詳解(五)配置鏈路聚合

man nmcli-examples

<code>[root@desktop0 ~]# man -k nmcli
nmcli (1)            - command - line tool for controlling ...
nmcli-examples (5)   - usage examples of nmcli/<code>
<code>[root@desktop0 ~]# man nmcli-examples | grep team | grep \\\\$
<standard>:183: warning [p 2, 7.7i]: can't break line
           $ nmcli con add type team con-name Team1 ifname Team1 config team1-master-json.conf
           $ nmcli con add type team-slave con-name Team1-slave1 ifname em1 master Team1
           $ nmcli con add type team-slave con-name Team1-slave2 ifname em2 master Team1/<standard>/<code>
<code>[root@desktop0 ~]# man teamd.conf | grep backup
              activebackup — Watches for  link  changes  and
              Default for activebackup runner: 1
              Default for activebackup runner: 1
         "runner": {"name": "activebackup"},
       This configuration  uses  active-backup  runner  with
         "runner": {"name": "activebackup"},
         "runner": {"name": "activebackup"},
       "runner": {"name": "activebackup"},/<code>

(2)複製上述命令,在Server0上修改相關配置,補全內容即可:

第一步:teamed的配置

<code> [root@server0 ~]# nmcli con add type team con-name Team1 ifname Team1 config '{"runner": {"name": "activebackup"}}'
Connection 'Team1' (ce8cdd24-03a9-4bfe-9c35-900b14c0f279) successfully added.
[root@server0 ~]# nmcli con add type team-slave con-name Team1-slave1 ifname eth1 master Team1
Connection 'Team1-slave1' (465600d7-8aa2-4e2c-b6f6-d5d9b8138d07) successfully added.
[root@server0 ~]# nmcli con add type team-slave con-name Team1-slave2 ifname eth2 master Team1
Connection 'Team1-slave2' (e4908548-7eef-44bf-a83b-bbacb13cf179) successfully added./<code>

第二步:為Team1接口配置IP地址

<code>[root@server0 ~]# nmcli connection modify Team1 ipv4.method manual ipv4.addresses 192.168.0.11/24 connection.autoconnect true
[root@server0 ~]# systemctl restart network/<code>

(3)查看驗證驗證Server0的配置:

<code>[root@server0 ~]# teamdctl Team1 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/<code>
<code>[root@server0 ~]# ping -c 3 192.168.0.11
PING 192.168.0.11 (192.168.0.11) 56(84) bytes of data.
64 bytes from 192.168.0.11: icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from 192.168.0.11: icmp_seq=2 ttl=64 time=0.107 ms
64 bytes from 192.168.0.11: icmp_seq=3 ttl=64 time=0.056 ms
--- 192.168.0.11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.050/0.071/0.107/0.025 ms/<code>

(4)在Desktop0上重複上述操作配置

<code>[root@desktop0 ~]# nmcli con add type team con-name Team1 ifname Team1 config '{"runner": {"name": "activebackup"}}'
Connection 'Team1' (98692ec9-67b3-4757-a4e1-3a274e0d3199) successfully added.
[root@desktop0 ~]# nmcli con add type team-slave con-name Team1-slave1 ifname eth1 master Team1
Connection 'Team1-slave1' (9b76c92d-1454-43d0-9684-42a2814036c1) successfully added.
[root@desktop0 ~]# nmcli con add type team-slave con-name Team1-slave2 ifname eth2 master Team1
Connection 'Team1-slave2' (dfa79ef3-4ac0-41e0-9f82-d433a84f3580) successfully added.
[root@desktop0 ~]# nmcli connection modify Team1 ipv4.method manual ipv4.addresses 192.168.0.10/24 connection.autoconnect true/<code>

(5)查看驗證驗證Desktop0的配置:

<code>[root@desktop0 ~]# systemctl restart network
[root@desktop0 ~]# teamdctl Team1 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
[root@desktop0 ~]# ping -c 3 192.168.0.10
PING 192.168.0.10 (192.168.0.10) 56(84) bytes of data.
64 bytes from 192.168.0.10: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 192.168.0.10: icmp_seq=2 ttl=64 time=0.126 ms
64 bytes from 192.168.0.10: icmp_seq=3 ttl=64 time=0.407 ms
--- 192.168.0.10 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.043/0.192/0.407/0.155 ms/<code>


分享到:


相關文章: