提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
文章目录
概述
链路聚合(Link Aggregation)是一种网络技术,通过将多个网络连接(如物理端口)组合成一个逻辑连接,以实现更高的数据传输速率和冗余性。通常分为两种模式:静态链路聚合,动态链路聚合(LACP)。
一、静态链路聚合(Static Link Aggregation)
定义:又叫手工负载分担,在这种模式下,网络管理员手动配置聚合组。设备之间的链路聚合设置是固定的,不需要使用协议进行协调。
优点:
简单直接,适合网络规模小且稳定的环境。
缺点:
缺乏自动故障转移和负载均衡功能,配置更改需要手动进行。
二、配置静态链路聚合
S1
#
interface Eth-Trunk1
mode manual load-balance ##设置为手动模式
#
interface GigabitEthernet0/0/1
eth-trunk 1 ##添加到 Eth-Trunk1 聚合组中
#
interface GigabitEthernet0/0/2
eth-trunk 1
#
S2
#
interface Eth-Trunk1
mode manual load-balance ##设置为手动模式
trunkport GigabitEthernet 0/0/1 TO 0/0/2 ##把这些接口添加到 Eth-Trunk 聚合组中
效果图
[S1]display eth-trunk 1
Eth-Trunk1's state information is:
WorkingMode: NORMAL Hash arithmetic: According to SIP-XOR-DIP
Least Active-linknumber: 1 Max Bandwidth-affected-linknumber: 8
Operate status: up Number Of Up Port In Trunk: 2
--------------------------------------------------------------------------------
PortName Status Weight
GigabitEthernet0/0/1 Up 1
GigabitEthernet0/0/2 Up 1
WorkingMode 工作模式:正常
Hash arithmetic: According to SIP-XOR-DIP 这表示流量负载均衡是基于源IP地址和目标IP地址的异或运算来分配到不同的物理链路上。
Least Active-linknumber: 1 至少需要有一个链路处于活跃状态以保证正常工作。
Max Bandwidth-affected-linknumber: 8 最多可以有8条链路影响整体的带宽决策。
Operate status: up 操作状态:正常运行
Number Of Up Port In Trunk: 2 聚合组中处于正常状态的端口数量:2
测试
在S1手动断开链路
interface GigabitEthernet0/0/1
shutdown
总结:当一条链路断开或者发生故障时,另外一条链路会承担数据传输的作用。
三、动态链路聚合(Dynamic Link Aggregation)
定义:使用链路聚合控制协议(LACP,IEEE 802.3ad)来自动识别和配置聚合组。LACP可以动态管理链路的加入或移除。
优点:
自动化:简化了链路的管理和配置过程,能够实时地对链路状态进行调整。
故障转移:在某条链路失效时,能够自动重新分配流量。
负载均衡:更好地利用聚合链路的带宽。
缺点:
配置相对复杂,需要设备的支持,并且可能带来一定的协议开销。
四、配置动态链路聚合
S1
interface Eth-Trunk1
mode lacp-static ##设置为动态模式
#
interface GigabitEthernet0/0/1
eth-trunk 1
#
interface GigabitEthernet0/0/2
eth-trunk 1
#
interface GigabitEthernet0/0/3
eth-trunk 1
S2
interface Eth-Trunk1
mode lacp-static
#
interface GigabitEthernet0/0/1
eth-trunk 1
#
interface GigabitEthernet0/0/2
eth-trunk 1
#
interface GigabitEthernet0/0/3
eth-trunk 1
查看效果:
[S1]display eth-trunk 1
Eth-Trunk1's state information is:
Local:
LAG ID: 1 WorkingMode: STATIC
Preempt Delay: Disabled Hash arithmetic: According to SIP-XOR-DIP
System Priority: 32768 System ID: 4c1f-cccf-647b
Least Active-linknumber: 1 Max Active-linknumber: 8
Operate status: up Number Of Up Port In Trunk: 3
--------------------------------------------------------------------------------
ActorPortName Status PortType PortPri PortNo PortKey PortState Weight
GigabitEthernet0/0/1 Selected 1GE 32768 2 305 10111100 1
GigabitEthernet0/0/2 Selected 1GE 32768 3 305 10111100 1
GigabitEthernet0/0/3 Selected 1GE 32768 4 305 10111100 1
Partner:
--------------------------------------------------------------------------------
ActorPortName SysPri SystemID PortPri PortNo PortKey PortState
GigabitEthernet0/0/1 32768 4c1f-cc1e-48cf 32768 2 305 10111100
GigabitEthernet0/0/2 32768 4c1f-cc1e-48cf 32768 3 305 10111100
GigabitEthernet0/0/3 32768 4c1f-cc1e-48cf 32768 4 305 10111100
WorkingMode: STATIC 静态LACP
Preempt Delay: Disabled 抢占模式为:关闭
System Priority: 32768 聚合链路组的系统优先级,值越低优先级越高。
System ID: 4c1f-cccf-647b 设备标识符越小越优先
Local: System ID: 4c1f-cccf-647b 本端的设备标识符
Partner: SystemID 对端的设备标识符
常用配置
当链路出现故障时,执行抢占模式
<S1>
interface Eth-Trunk1
mode lacp-static
lacp preempt enable
lacp preempt delay 10
<S2>
interface Eth-Trunk1
mode lacp-static
lacp preempt enable
lacp preempt delay 10
修改优先级
[S1]display eth-trunk 1
Eth-Trunk1's state information is:
Local:
LAG ID: 1 WorkingMode: STATIC
Preempt Delay Time: 10 Hash arithmetic: According to SIP-XOR-DIP
System Priority: 32768 System ID: 4c1f-cccf-647b
Least Active-linknumber: 1 Max Active-linknumber: 8
Operate status: up Number Of Up Port In Trunk: 3
--------------------------------------------------------------------------------
ActorPortName Status PortType PortPri PortNo PortKey PortState Weight
GigabitEthernet0/0/1 Selected 1GE 32768 2 305 10111100 1
GigabitEthernet0/0/2 Selected 1GE 32768 3 305 10111100 1
GigabitEthernet0/0/3 Selected 1GE 32768 4 305 10111100 1
Partner:
--------------------------------------------------------------------------------
ActorPortName SysPri SystemID PortPri PortNo PortKey PortState
GigabitEthernet0/0/1 32768 4c1f-cc1e-48cf 32768 2 305 10111100
GigabitEthernet0/0/2 32768 4c1f-cc1e-48cf 32768 3 305 10111100
GigabitEthernet0/0/3 32768 4c1f-cc1e-48cf 32768 4 305 10111100
本端 Local SystemID: 4c1f-cccf-647b
对端 Partner SystemID: 4c1f-cc1e-48cf
判断依据
从左到右逐字节比较:
第一字节:4c 对比 4c,相同。
第二字节:1f 对比 1f,相同。
第三字节:cc 对比 cc,相同。
第四字节:cf 对比 1e,cf(即207)大于 1e(即30)。
由于第四字节 cf > 1e,因此本端的系统ID 大于对端的系统ID。
修该对端G0/0/2端口优先级:
interface GigabitEthernet0/0/2
eth-trunk 1
lacp priority 32767
在S1上查看状态:
Partner:
--------------------------------------------------------------------------------
ActorPortName SysPri SystemID PortPri PortNo PortKey PortState
GigabitEthernet0/0/1 32768 4c1f-cc1e-48cf 32768 2 305 10111100
GigabitEthernet0/0/2 32768 4c1f-cc1e-48cf 32767 3 305 10111100
GigabitEthernet0/0/3 32768 4c1f-cc1e-48cf 32768 4 305 10111100
发现对端G0/0/2优先级编成了32767
修改最大活动链路数量
[S1-Eth-Trunk1] max active-linknumber 2
[S2-Eth-Trunk1] max active-linknumber 2
##查看状态
[S1-Eth-Trunk1]display eth-trunk 1
Eth-Trunk1's state information is:
Local:
LAG ID: 1 WorkingMode: STATIC
Preempt Delay Time: 10 Hash arithmetic: According to SIP-XOR-DIP
System Priority: 32768 System ID: 4c1f-cccf-647b
Least Active-linknumber: 1 Max Active-linknumber: 2
Operate status: up Number Of Up Port In Trunk: 2
发现Max Active-linknumber: 2 改变了