1. 程式人生 > >CentOS7的聚合鏈路

CentOS7的聚合鏈路

1、環境介紹

[[email protected] ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
ENERAL.DEVICE:                         ens37
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:04:8C:9B
192.168.137.128/24
192.168.137.0/24
192.168.137.1

GENERAL.DEVICE:                         ens38
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:04:8C:A5
192.168.137.129/24
192.168.137.1
因為是在虛擬機器中進行的實驗只能進行高可用測試
聚合鏈路的幾種模式:
broadcast 傳輸所有埠進來的資料包
roundrobin 隨機計算髮送資料(輪詢)
activebackup  高可用性
loadbalance 負載均衡
josn的配置{"runner": {"name":"activebackup"}} ##模式修改只需修改這個格式中的name欄位的值

2、幾種做聚合鏈路的方式
2.1 圖形化

[[email protected] ~]# nmtui-edit

圖片.png
圖片.png
圖片.png
JSON配置模式在team0這個虛擬網卡里配置
配置完成後重啟網絡卡

[[email protected] ~]# systemctl restart network
[[email protected] ~]# ip a
---
5: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
6: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
10: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff
    inet 192.168.137.128/24 brd 192.168.137.255 scope global noprefixroute team0
       valid_lft forever preferred_lft forever
    inet6 fe80::f39f:f544:b69f:48db/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
---

2.2 命令列

第一種
[[email protected] ~]# man nmcli-examples
找到以下照著模板抄
           $ nmcli con add type team con-name Team1 ifname Team1 config team1-ma
ster-json.conf
           $ nmcli con add type ethernet con-name Team1-slave1 ifname em1 master
 Team1
           $ nmcli con add type ethernet con-name Team1-slave2 ifname em2 master
 Team1
這是我本地的網絡卡名稱
ens37:  link/ether 00:0c:29:04:8c:9b
ens38:  link/ether 00:0c:29:04:8c:a5

[
[email protected]
~]# nmcli con add type team con-name Team1 ifname Team1 config '{"runner":{"name":"activebackup"}}' [[email protected] ~]# nmcli con add type ethernet con-name Team1-slave1 ifname ens37 master Team1 [[email protected] ~]# nmcli con add type ethernet con-name Team1-slave2 ifname ens38 master Team1 第二種 [[email protected] 1]# pwd /usr/share/doc/teamd-1.27/example_ifcfgs/1 [[email protected] 1]# ls ifcfg-eth1 ifcfg-eth2 ifcfg-team_test0 這裡是team的模板配置檔案,直接複製到網絡卡的配置檔案目錄修改修改 cd /etc/sysconfig/network-scripts/ 18 ls 19 mv ifcfg-eth1 ifcfg-ens37 20 mv ifcfg-eth2 ifcfg-ens38 21 vim ifcfg-ens37 22 vim ifcfg-ens38 23 vim ifcfg-team_test0 24 systemctl restart network [[email protected] network-scripts]# cat ifcfg-ens37;cat ifcfg-ens38 DEVICE="ens37" DEVICETYPE="TeamPort" ONBOOT="yes" TEAM_MASTER="team_test0" DEVICE="ens38" DEVICETYPE="TeamPort" ONBOOT="yes" TEAM_MASTER="team_test0" [[email protected] network-scripts]# cat ifcfg-team_test0 DEVICE="team_test0" DEVICETYPE="Team" ONBOOT="yes" BOOTPROTO=none NETMASK=255.255.255.0 IPADDR=192.168.137.128 GATEWAY=192.168.137.1 TEAM_CONFIG='{"runner": {"name": "roundrobin"}}' 5: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team_test0 state UP group default qlen 1000 link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff 6: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team_test0 state UP group default qlen 1000 link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff 7: team_test0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:0c:29:04:8c:9b brd ff:ff:ff:ff:ff:ff inet 192.168.137.128/24 brd 192.168.137.255 scope global noprefixroute team_test0

3、總結
鏈路聚合主要是備份網絡卡,實現網絡卡互動工作,避免網絡卡單點故障,提高系統的可靠性。其中除了做熱備份(activebackup)連線冗餘,其他的模式是需要交換機做[EtherChannel (PAgP and LACP) 以太通道]

簡書連結
END