多生成樹(MST)是把IEEE802.1w 的快速生成樹(RST)算法擴展而獲得的,多生成樹協議定義文檔是IEEE802.1S。css
多生成樹提出了域的概念,在域的內部能夠生成多個生成樹實例,並將VLAN關聯到相應的實例中,每一個VLAN只能關聯到一個實例中。這樣在域內部每一個生成樹實例就造成一個邏輯上的樹拓撲結構,在域與域之間由CIST實例將各個域連成一個大的生成樹。各個VLAN內的數據在不一樣的生成樹實例內進行轉發,這樣就提供了負載均衡功能。算法
MSTP(Multiple Spanning Tree Protocol,多生成樹協議)服務器
將存在環路的網絡修剪成爲一個無環的樹型網絡,避免報文在環路網絡中的增生和無限循環,同時還提供了數據轉發的多個冗餘路徑,在數據轉發過程當中實現VLAN 數據的負載均衡。MSTP 兼容STP 和RSTP,而且能夠彌補STP 和RSTP 的缺陷。它既能夠快速收斂,也能使不一樣VLAN 的流量沿各自的路徑分發,從而爲冗餘鏈路提供了更好的負載分擔機制。網絡
MSTP與其餘幾種生成樹協議對比:
app
實驗模擬
實驗拓撲如上圖所示。設PC八、九、10爲vlan 10中的設備,PC十一、12/13爲vlan 20中的設備,使SW-1成爲vlan 10的根橋交換機,SW-2成爲vlan 20的交換機。要求:運行MSTP,防止環路存在,同時實現負載均衡。
注意:運行MSTP須要在每臺交換機上都進行配置。負載均衡
SW-1ide
SW-1(config)#interface range g0/0-1 SW-1(config-if-range)#switchport trunk encapsulation dot1q SW-1(config-if-range)#switchport mode trunk SW-1(config-if-range)#exit SW-1(config)#interface range g1/0-1 SW-1(config-if-range)#switchport trunk encapsulation dot1q SW-1(config-if-range)#switchport mode trunk SW-1(config-if-range)#exit SW-1(config)#vlan 10 SW-1(config-vlan)#vlan 20 SW-1(config-vlan)#exit SW-1(config)#spanning-tree mode mst //進入MSTP的配置模式下 SW-1(config)#spanning-tree mst configuration //設置域名,全部運行MSTP的設備應當一致 SW-1(config-mst)#name cisco SW-1(config-mst)#revision 1//設置版本號 //建立實例 SW-1(config-mst)#instance 1 vlan 10 SW-1(config-mst)#instance 2 vlan 20 //查看實例信息 SW-1(config-mst)#show pending Pending MST configuration Name [cisco] Revision 1 Instances configured 3 Instance Vlans mapped -------- --------------------------------------------------------------------- 0 1-9,11-19,21-4094 1 10 2 20 ------------------------------------------------------------------------------- SW-1(config-mst)#exit //基於實例設置優先級 SW-1(config)#spanning-tree mst 1 priority 0 SW-1(config)#spanning-tree mst 2 priority 4096 //檢查配置是否正確 SW-1(config)#do show running-config | section spanning-tree spanning-tree mode mst spanning-tree extend system-id spanning-tree mst configuration name cisco revision 1 instance 1 vlan 10 instance 2 vlan 20 spanning-tree mst 1 priority 0 spanning-tree mst 2 priority 4096 //另外一種設置實例優先級的方法 SW-(config)#spanning-tree mst 1 root primary
SW-2ui
SW-2(config)#interface range g0/0-1 SW-2(config-if-range)#switchport trunk encapsulation dot1q SW-2(config-if-range)#switchport mode trunk SW-2(config-if-range)#exit SW-2(config)#interface range g1/0-1 SW-2(config-if-range)#switchport trunk encapsulation dot1q SW-2(config-if-range)#switchport mode trunk SW-2(config-if-range)#exit SW-2(config)#vlan 10 SW-2(config-vlan)#vlan 20 SW-2(config-vlan)#exit SW-2(config)#spanning-tree mode mst SW-2(config)#spanning-tree mst configuration SW-2(config-mst)#name cisco SW-2(config-mst)#revision 1 SW-2(config-mst)#instance 1 vlan 10 SW-2(config-mst)#instance 2 vlan 20 SW-2(config-mst)#exit SW-2(config)#spanning-tree mst 1 priority 4096 SW-2(config)#spanning-tree mst 2 priority 0 //檢查配置是否正確 SW-2(config)#do show running-config | section spanning-tree spanning-tree mode mst spanning-tree extend system-id spanning-tree mst configuration name cisco revision 1 instance 1 vlan 10 instance 2 vlan 20 spanning-tree mst 1 priority 4096 spanning-tree mst 2 priority 0 //另外一種設置實例優先級的方法 SW-2(config)#spanning-tree mst 2 root primary
SW-3this
SW-3(config)#interface range g0/1-2 SW-3(config-if-range)#switchport trunk encapsulation dot1q SW-3(config-if-range)#switchport mode trunk SW-3(config-if-range)#exit SW-3(config)#vlan 10 SW-3(config-vlan)#exit SW-3(config)#interface range g1/0-2 SW-3(config-if-range)#switchport mode access SW-3(config-if-range)#switchport access vlan 10 SW-3(config-if-range)#exit SW-3(config)#spanning-tree mode mst SW-3(config)#spanning-tree mst configuration SW-3(config-mst)#name cisco SW-3(config-mst)#revision 1 SW-3(config-mst)#instance 1 vlan 10 SW-3(config-mst)#exit //查看實例信息 SW-3(config)#do show spanning-tree mst 1 ##### MST1 vlans mapped: 10 Bridge address 5000.0003.0000 priority 32769 (32768 sysid 1) Root this switch for MST1 Interface Role Sts Cost Prio.Nbr Type ---------------- ---- --- --------- -------- -------------------------------- Gi0/1 Altn BLK 20000 128.2 Shr Bound(RSTP) Gi0/2 Mstr FWD 20000 128.3 Shr Bound(RSTP) Gi1/0 Desg FWD 20000 128.5 Shr Gi1/1 Desg FWD 20000 128.6 Shr Gi1/2 Desg FWD 20000 128.7 Shr
SW-4spa
SW-4(config)#interface range g0/1-2 SW-4(config-if-range)#switchport trunk encapsulation dot1q SW-4(config-if-range)#switchport mode trunk SW-4(config-if-range)#exit SW-4(config)#vlan 20 SW-4(config-vlan)#exit SW-4(config)#interface range g1/0-2 SW-4(config-if-range)#switchport mode access SW-4(config-if-range)#switchport access vlan 20 SW-4(config-if-range)#exit SW-4(config)#spanning-tree mode mst SW-4(config)#spanning-tree mst configuration SW-4(config-mst)#name cisco SW-4(config-mst)#revision 1 SW-4(config-mst)#instance 2 vlan 20 SW-4(config-mst)#exit
經過查看端口狀態,可驗證無環路要求已實現。要想實現負載均衡,還需進行鏈路聚合的相關配置。
鏈路聚合是將兩個或更多數據信道結合成一個單個的信道,該信道以一個單個的更高帶寬的邏輯鏈路出現。鏈路聚合通常用來鏈接一個或多個帶寬需求大的設備,例如鏈接骨幹網絡的服務器或服務器羣。
端口匯聚是將多個端口匯聚在一塊兒造成一個匯聚組,以實現出/入負荷在匯聚組中各個成員端口中的分擔,同時也提供了更高的鏈接可靠性。
公有:LACP(Link Aggregation Control Protocol,鏈路匯聚控制協議)。是一種實現鏈路動態匯聚的協議。LACP協議經過LACPDU(Link Aggregation Control Protocol Data Unit,鏈路匯聚控制協議數據單元)與對端交互信息。啓用某端口的LACP協議後,該端口將經過發送LACPDU向對端通告本身的系統優先級、系統MAC地址、端口優先級、端口號和操做Key。對端接收到這些信息後,將這些信息與其它端口所保存的信息比較以選擇可以匯聚的端口,從而雙方能夠對端口加入或退出某個動態匯聚組達成一致。
操做Key是在端口匯聚時,LACP協議根據端口的配置(即速率、雙工、基本配置、管理Key)生成的一個配置組合。動態匯聚端口在啓用LACP協議後,其管理Key缺省爲零。靜態匯聚端口在啓用LACP後,端口的管理Key與匯聚組ID相同。
私有:端口彙集協議(PAgP)(Port Aggregation Protocol)是Cisco的專有協議,PAgP是一種管理功能,它在鏈路的任一末端檢查參數的一致性,而且有助於保持網絡可用性。 PAgP 分組爲了商議一個通道的造成在快速以太通道可能的端口發送。
主動模式:主動發送協商包,主動發起協商
被動模式:接收協商包,進行協商
LACP;聚合鏈路能夠爲二、四、八、16條。最大能夠聚合鏈路爲8條,剩餘8條做爲備份存在。
PAgP:二、四、8條。
SW-1
SW-1(config)#interface range g1/0-1 //描述協議信息,與具體使用什麼協議無關 SW-1(config-if-range)#channel-protocol lacp //設置聚合組編號 SW-1(config-if-range)#channel-group 1 mode passive //查看配置信息 SW-1(config)#do sh etherchannel summary Flags: D - down P - bundled in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use N - not in use, no aggregation f - failed to allocate aggregator M - not in use, minimum links not met m - not in use, port not aggregated due to minimum links not met u - unsuitable for bundling w - waiting to be aggregated d - default port A - formed by Auto LAG Number of channel-groups in use: 1 Number of aggregators: 1 Group Port-channel Protocol Ports ------+-------------+-----------+----------------------------------------------- 1 Po1(SD) LACP Gi1/0(s) Gi1/1(s)
SW-2
SW-2(config)#interface range g1/0-1 SW-2(config-if-range)#channel-protocol lacp SW-2(config-if-range)#channel-group 1 mode active /*提示信息:Creating a port-channel interface Port-channel 1*/ //查看配置信息 SW-2(config)#do show etherchannel summary Flags: D - down P - bundled in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use N - not in use, no aggregation f - failed to allocate aggregator M - not in use, minimum links not met m - not in use, port not aggregated due to minimum links not met u - unsuitable for bundling w - waiting to be aggregated d - default port A - formed by Auto LAG Number of channel-groups in use: 1 Number of aggregators: 1 Group Port-channel Protocol Ports ------+-------------+-----------+----------------------------------------------- 1 Po1(SU) LACP Gi1/0(P) Gi1/1(P)
經過查看帶寬信息,咱們能夠發現SW-2的帶寬從以前的1G變爲如今的2G,實現了鏈路聚合。
鏈路聚合默認狀況下基於源目IP負載(可修改)
//可修改成下列幾種負載方式 SW-2(config)#port-channel load-balance ? dst-ip Dst IP Addr dst-mac Dst Mac Addr src-dst-ip Src XOR Dst IP Addr src-dst-mac Src XOR Dst Mac Addr src-ip Src IP Addr src-mac Src Mac Addr
其餘查看配置命令:
SW-2(config)#do show run | section channel interface Port-channel1 switchport trunk encapsulation dot1q switchport mode trunk channel-protocol lacp channel-group 1 mode active channel-protocol lacp channel-group 1 mode active SW-2(config)#do show run | section channel-group channel-group 1 mode active channel-group 1 mode active SW-2(config)#do show etherchannel load-balance EtherChannel Load-Balancing Configuration: src-dst-ip EtherChannel Load-Balancing Addresses Used Per-Protocol: Non-IP: Source XOR Destination MAC address IPv4: Source XOR Destination IP address IPv6: Source XOR Destination IP address
當存在兩條聚合鏈路時,可經過設置優先級的狀況下改變鏈路使用狀態
查看默認狀況下的聚合鏈路信息
SW-2(config)#do show etherchannel port Channel-group listing: ---------------------- Group: 1 ---------- Ports in the group: ------------------- Port: Gi1/0 ------------ Port state = Up Mstr Assoc In-Bndl Channel group = 1 Mode = Active Gcchange = - Port-channel = Po1 GC = - Pseudo port-channel = Po1 Port index = 0 Load = 0x00 Protocol = LACP Flags: S - Device is sending Slow LACPDUs F - Device is sending fast LACPDUs. A - Device is in active mode. P - Device is in passive mode. Local information: LACP port Admin Oper Port Port Port Flags State Priority Key Key Number State Gi1/0 SA bndl 32768 0x1 0x1 0x101 0x3D Partner's information: LACP port Admin Oper Port Port Port Flags Priority Dev ID Age key Key Number State Gi1/0 SP 32768 5000.0001.0000 8s 0x0 0x1 0x101 0x3C Age of the port in the current state: 0d:00h:15m:49s Port: Gi1/1 ------------ Port state = Up Mstr Assoc In-Bndl Channel group = 1 Mode = Active Gcchange = - Port-channel = Po1 GC = - Pseudo port-channel = Po1 Port index = 0 Load = 0x00 Protocol = LACP Flags: S - Device is sending Slow LACPDUs F - Device is sending fast LACPDUs. A - Device is in active mode. P - Device is in passive mode. Local information: LACP port Admin Oper Port Port Port Flags State Priority Key Key Number State Gi1/1 SA bndl 32768 0x1 0x1 0x102 0x3D Partner's information: LACP port Admin Oper Port Port Port Flags Priority Dev ID Age key Key Number State Gi1/1 SP 32768 5000.0001.0000 11s 0x0 0x1 0x102 0x3C Age of the port in the current state: 0d:00h:15m:47s
觀察相關的信息咱們能夠發現,默認優先級爲32768.
修改方法:
SW-2(config)#interface g1/0 SW-2(config-if)#lacp por SW-2(config-if)#lacp port-priority ? <0-65535> Priority value
須要注意的是,若修改聚合鏈路優先級,應當將本端口和對端端口的優先級進行同步配置,不可只配置一個端口。