基于Centos6.6的R720服务器四网口端口聚合的实践

时间:2023-03-09 21:42:45
基于Centos6.6的R720服务器四网口端口聚合的实践

服务器多网口端口聚合,其目的主要在于网卡容灾和提升带宽。linux端口绑定,提供7种模式,如下:

关于mode共有0-6等7种模式,详细请参考官方手册!
mode的值表示工作模式,他共有0,1,2,3,4,5,6这7种模式,常用的为0,1两种。
mode=0表示load balancing (round-robin)为负载均衡方式,两块网卡都工作。
mode=1表示fault-tolerance (active-backup)提供冗余功能,工作方式是主备的工作方式,也就是说默认情况下只有一块网卡工作,另一块做备份。
mode=2表示balance-x,提供负载均衡和冗余功能。
mode=3表示broadcast,这个模式提供容错性。
mode=4表示802.3ad,提供了ethtool的迅速,以及使用了802.3ad模式。
mode=5表示balance-tlb,自动适应负载均衡,自动切换故障。在此基础上Ethtool支持驱动。
mode=6表示在5模式的基础上优化了arp的广播信息。

下面主要说下mode=4的802.3ad模式的配置方式,02.3ad的支持需要服务器和交换机同时支持,配置方面也是需要两端进行。

IEEE 802.3ad概念 是执行链路聚合的标准方法。从概念上讲,将多个以太网适配器聚集到单独的虚拟适配器方面与“以太通道(EtherChannel)”的功能相同,能提供更高的带宽防止发生故障。例如,ent0 和 ent1 可以聚集到称作 ent3 的 IEEE 802.3ad 链路聚合;然后用 IP 地址配置接口 en3。系统将这些聚集的适配器作为一个适配器来考虑。因此,可以像在任何以太网适配器上一样配置它们的 IP。

linux服务器配置,服务器配置需要配置两个地方,一个是网卡配置,一个是绑定模块配置

#在/etc/sysconfig/network-script/目录中增加ifcfg-bond0文件

#ifcfg-bond0
BOOTPROTO=none
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.1.61
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
USERCTL=no
TYPE=Ethernet
DNS1=192.168.1.1 #修改实体网卡的配置
DEVICE=em1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none #主要是增加如下几行
MASTER=bond0
SLAVE=yes
USERCTL=no #进入/etc/modprobe.d/修改dist.conf配置文件
#在文件尾增加,miimon为检查时间,mode为端口绑定模式
alias bond0 bonding
options bond0 miimon= mode=

交换机配置,需要交换机支持802.3ad,具体步骤为先创建eth-trunk口,然后将口提升为lacd,本例才用华为s5352型号交换机

#创建eth-trunk端口

[Huawei]int eth-trunk             #创建eth-trunk
[Huawei-Eth-Trunk1]int g0//
[Huawei-GigabitEthernet0//]eth-trunk #将10口加入到eth-trunk
[Huawei]vlan
[Huawei-vlan2]int eth-trunk
[Huawei-Eth-Trunk1]port default vlan #将eth-trunk加入到vlan 2中
[Huawei-Eth-Trunk1]dis vlan VID Type Ports
--------------------------------------------------------------------------------
common UT:GE0//(D) GE0//(D) GE0//(D) GE0//(D)
GE0//(D) GE0//(D) GE0//(D) GE0//(D)
GE0//(D) GE0//(U) GE0//(U) GE0//(U)
GE0//(D) GE0//(D) GE0//(D) GE0//(D)
GE0//(D) GE0//(D) GE0//(D) GE0//(D)
GE0//(D) GE0//(D) GE0//(D)
common UT:Eth-Trunk1(U) VID Status Property MAC-LRN Statistics Description
--------------------------------------------------------------------------------
enable default enable disable VLAN
enable default enable disable VLAN

关键步骤,将eth-trunk模式转化为 LACP

[Huawei-Eth-Trunk1]mode lacp-static

[Quidway]dis eth-trunk
Eth-Trunk1's state information is:
Local:
LAG ID: 1 WorkingMode: LACP
Preempt Delay: Disabled Hash arithmetic: According to SA-XOR-DA
System Priority: 32768 System ID: 5439-df15-6110
Least Active-linknumber: 1 Max Active-linknumber: 8
Operate status: up Number Of Up Port In Trunk: 4
--------------------------------------------------------------------------------
ActorPortName Status PortType PortPri PortNo PortKey PortState Weight
GigabitEthernet0/0/21 Selected 1GE 32768 1 305 10111100 1
GigabitEthernet0/0/22 Selected 1GE 32768 2 305 10111100 1
GigabitEthernet0/0/23 Selected 1GE 32768 3 305 10111100 1
GigabitEthernet0/0/24 Selected 1GE 32768 4 305 10111100 1 Partner:
--------------------------------------------------------------------------------
ActorPortName SysPri SystemID PortPri PortNo PortKey PortState
GigabitEthernet0/0/21 65535 f8bc-1250-6e74 255 2 17 10111100
GigabitEthernet0/0/22 65535 f8bc-1250-6e74 255 4 17 10111100
GigabitEthernet0/0/23 65535 f8bc-1250-6e74 255 3 17 10111100
GigabitEthernet0/0/24 65535 f8bc-1250-6e74 255 1 17 10111100

设置完成后,重启服务器,并保存交换机配置。

重启完成后,查看绑定配置

[had@Slave1 ~]$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.6.0 (September , ) Bonding Mode: IEEE .3ad Dynamic link aggregation
Transmit Hash Policy: layer2 ()
MII Status: up
MII Polling Interval (ms):
Up Delay (ms):
Down Delay (ms): .3ad info
LACP rate: slow
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
Aggregator ID:
Number of ports: #这个地方非常关键,如果你绑定了几个端口,就要现实几,否则则未成功
Actor Key:
Partner Key:
Partner Mac Address: ::df:::xx Slave Interface: em1
MII Status: up
Speed: Mbps
Duplex: full
Link Failure Count:
Permanent HW addr: f8:bc:::6e:xx
Aggregator ID:
Slave queue ID: Slave Interface: em2
MII Status: up
Speed: Mbps
Duplex: full
Link Failure Count:
Permanent HW addr: f8:bc:::6e:xx
Aggregator ID:
Slave queue ID: Slave Interface: em3
MII Status: up
Speed: Mbps
Duplex: full
Link Failure Count:
Permanent HW addr: f8:bc:::6e:xx
Aggregator ID:
Slave queue ID: Slave Interface: em4
MII Status: up
Speed: Mbps
Duplex: full
Link Failure Count:
Permanent HW addr: f8:bc:::6e:xx
Aggregator ID:
Slave queue ID: