端口聚合可以提高交换机的吞吐量和高可用性,不同厂家的交换机,其端口聚合的配置不尽相同。本文仅涉及华为和h3c两个厂家的配置。

服务器两个端口跟一台华为5328交换机的7和8口配置成端口聚合。采用的是lacp/802.3ad协议。华为交换机支持静态lacp协议,但不支持动态lacp。

1. 华为交换机S5328

1.1 配置

# 清掉物理接口下的配置
int GigabitEthernet 0/0/7
undo ndp enable
undo ntdp enable
undo port def vlan
bpdu disable
quit
 
int GigabitEthernet 0/0/8
undo ndp enable
undo ntdp enable
undo port def vlan
bpdu disable
quit

# 创建eth-trunk 
int eth-trunk 1
# 在bond口中,并不接收bpdu数据包,因此此指令是多余的
# bpdu enable
ndp enable
ntdp enable
port def vlan 55
mode lacp-static
lacp timeout fast
load-blan src-ip
quit

1.2 两种增、删聚合口的操作

  1. eth-trunk端口下

    • 增加

      trunkport gigabitethernet 0/0/7
      trunkport gigabitethernet 0/0/8
    • 删除

    undo trunkport gigabitethernet 0/0/7
    undo trunkport gigabitethernet 0/0/8
  2. 分别在各自的物理端口下:

    • 增加

      int GigabitEthernet 0/0/7
      eth-trunk 1
      quit
       
      int GigabitEthernet 0/0/8
      eth-trunk 1
      quit
    • 删除

      int GigabitEthernet 0/0/7
      undo eth-trunk 1
      quit
      
      int GigabitEthernet 0/0/8
      undo eth-trunk 1
      quit

1.3 查看聚合端口状态

>dis eth-trunk 1
Eth-Trunk1's state information is:
WorkingMode: NORMAL         Hash arithmetic: According to SIP                
Least Active-linknumber: 1  Max Bandwidth-affected-linknumber: 8             
Operate status: up          Number Of Up Port In Trunk: 2                    
--------------------------------------------------------------------------------
PortName                      Status      Weight
GigabitEthernet0/0/8          Up          1     
GigabitEthernet0/0/7          Up          1   

1.4 查看聚合端口统计

>dis lacp statistics eth-trunk 1
 Eth-Trunk1's PDU statistic is:
 ------------------------------------------------------------------------------
 Port                    LacpRevPdu   LacpSentPdu  MarkerRevPdu MarkerSentPdu
 GigabitEthernet0/0/7    3202028      4109548      0            0
 GigabitEthernet0/0/8    3198516      4109020      0            0

默认情况下的lacp timeout为slow(30秒),所以通过该命令可以查看到LacpRevPdu的计数为每30秒增加1,当在交换机中配置了lacp timeout fast(1秒)之后,通过该命令就会发现LacpRevPdu的计数每秒增加1。

1.5 测试端口聚合的效果

两台服务器srvA和srvB,一台华为交换机hw-sw,其中srvB的eth0和eth1和hw-sw的ge1/0/1和ge1/0/2做了端口聚合。

启动两个方向的ping:

  • srvA ping srvB

  • srvB ping srvA

通过tcpdump确定srvB当前所起作用的端口为eth1。

[srvB]: $ sudo ifconfig eth1 down
  • 观察srvA ping srvB,发现有30秒的icmp reply中断,随后通过srvB的eth0发生交互。

  • 观察srvB ping srvA,没有icmp reply中断情况。

[srvB]: $ sudo ifconfig eth1 up
  • 观察srvA ping srvB,没有icmp reply中断情况。

  • 观察srvB ping srvA,没有icmp reply中断情况。

2. h3c交换机S5800

在做端口聚合时,华三5800跟华为5300的配置有很大的不同。

>dis cur
------------8<------------
interface Bridge-Aggregation19
 description "DL585g7(master)'s bond0"
 port link-type trunk
 undo port trunk permit vlan 1
 port trunk permit vlan 20 24 28 111 300
 link-aggregation mode dynamic

interface GigabitEthernet1/0/19
 port link-mode bridge
 description "DL585g7:port1(master)"
 port link-type trunk
 undo port trunk permit vlan 1
 port trunk permit vlan 20 24 28 111 300
 port link-aggregation group 19

interface GigabitEthernet2/0/19
 port link-mode bridge
 description "DL585g7:port2(master)"
 port link-type trunk
 undo port trunk permit vlan 1
 port trunk permit vlan 20 24 28 111 300
 port link-aggregation group 19
------------>8------------

需要注意的是,在物理接口下,无需配置port的相关属性,只需要如下配置即可:

port link-aggregation group 19

配置步骤如下:

interface Bridge-Aggregation19
 description "DL585g7(master)'s bond0"
 link-aggregation mode dynamic
 quit

interface GigabitEthernet1/0/19
 port link-mode bridge
 description "DL585g7:port1(master)"
 port link-aggregation group 19
 quit
interface GigabitEthernet2/0/19
 port link-mode bridge
 description "DL585g7:port2(master)"
 port link-aggregation group 19
 quit

interface Bridge-Aggregation19
 port link-type trunk
 undo port trunk permit vlan 1
 port trunk permit vlan 20 24 28 111 300
 quit

假如需要在聚合组中添加新的物理端口,则需要在Bridge-Aggregation19接口模式下,重做一遍port link-type、port trunk permit等。这种配置方式很不方便,但是不知道为什么hp/h3c一直没有改过来,很任性!