linux内核端口绑定,linux 多网卡bonding 绑定 端口聚合

将多个Linux网络端口绑定为一个,可以提升网络的性能,比如对于备份服务器,需要在一个晚上备份几个T的数据,

如果使用单个的千兆网口将会是很严重的瓶颈。其它的应用,比如ftp服务器,高负载的下载网站, 都有类似的问题。

因此使用Linux teaming或bond来绑定多个网卡作为一个逻辑网口,配置单个的IP地址,会大幅提升服务器的网络吞吐(I/O)。

Linux的多网卡绑定功能使用的是内核中的"bonding"模块,关于此模块可以参考Linux Ethernet Bonding Driver文档,

但是目前发布各个Linux版本内核均已包含了此模块,大多数情况下不需要重新编译内核。

Linux 的 bonding 驱动提供了绑定/集成(bond)多个网卡为一个虚拟逻辑网口的功能。并请注意绑定的网口(bonded)有多种工作模式;

一般来说,分为 热后备(hot standby) 和 负载均衡(load balancing). 在Redhat/Fedora和其它类Redhat Linux中是比较容易配置的。

1.创建bond0配置文件

vi /etc/sysconfig/network-scripts/ifcfg-bond0

[root@localhost network-scripts]# less ifcfg-bond0

DEVICE=bond0

#HWADDR=00:10:18:D8:62:58

TYPE=Ethernet

#UUID=85f545ec-5add-48e0-bcc6-3699a2202972

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

IPADDR=192.168.2.10

NETMASK=255.255.255.0

GATEWAY=192.168.2.1

MTU=9000

BONDING_OPTS="mode=4 miimon=100"

2.修改被绑定的eth0和eth1的配置文件

[root@localhost network-scripts]# cat ifcfg-eth2

DEVICE=eth2

HWADDR=00:10:18:D8:62:58

TYPE=Ethernet

UUID=85f545ec-5add-48e0-bcc6-3699a2202972

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

MTU=9000

[root@localhost network-scripts]# cat ifcfg-eth3

DEVICE=eth3

#HWADDR=00:10:18:D8:62:58

TYPE=Ethernet

UUID=85f545ec-5add-48e0-bcc6-3699a2202972

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

MTU=9000

[root@localhost network-scripts]# cat ifcfg-eth4

DEVICE=eth4

#HWADDR=00:10:18:D8:62:58

TYPE=Ethernet

UUID=85f545ec-5add-48e0-bcc6-3699a2202972

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

MTU=9000

[root@localhost network-scripts]# cat ifcfg-eth5

DEVICE=eth5

#HWADDR=00:10:18:D8:62:58

TYPE=Ethernet

UUID=85f545ec-5add-48e0-bcc6-3699a2202972

ONBOOT=yes

NM_CONTROLLED=no

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

MTU=9000

3.装在bond模块驱动

编辑/etc/modprobe.conf或者/etc/modules.conf文件,加入如下内容,使系统启动时加载bonding模块驱动

如果没有modprobe.conf 就vi modprobe.conf 一个文件

alias bond0 bonding

option bond0 miimon=100 mode=1

说明:

1).miimon=100 用来进行链路监测的。即每100ms监测一次链路状态。bonding只监测主机与交换机之间链路。如果交换机出去的链路出问题而本身没有问题,那么bonding认为链路没有问题而继续使用。

2).mode=1 表示提供冗余功能。除此之外还可以为0、2、3,共四种模式。0表示负载均衡

4.在/etc/rc.d/rc.local文件中加入如下语句,使得系统启动自动运行

ifenslave bond0 eth0 eth1

route add -net 192.168.1.254 netmask 255.255.255.0 bond0 #如有需要才加该路由

5.检测、验证配置

首先执行命令装载bonding模块:modprobe bonding

重启网络服务,并确认bond0正确启动:service network restart

确认设备已经正确加载:less /proc/net/bonding/bond0

[root@localhost network-scripts]# less /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation

Transmit Hash Policy: layer2 (0)

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

802.3ad info

LACP rate: slow

Aggregator selection policy (ad_select): stable

Active Aggregator Info:

Aggregator ID: 15

Number of ports: 1

Actor Key: 17

Partner Key: 1

Partner Mac Address: 00:00:00:00:00:00

Slave Interface: eth2

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 5

Permanent HW addr: 00:10:18:d8:62:58

Aggregator ID: 12

Slave queue ID: 0

Slave Interface: eth3

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 1

Permanent HW addr: 00:10:18:d8:62:5a

Aggregator ID: 13

Slave queue ID: 0

Slave Interface: eth4

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 2

Permanent HW addr: 00:10:18:d8:62:5c

Aggregator ID: 14

Slave queue ID: 0

Slave Interface: eth5

MII Status: up

Speed: 1000 Mbps

Duplex: full

Link Failure Count: 0

Permanent HW addr: 00:10:18:d8:62:5e

Aggregator ID: 15

Slave queue ID: 0

至此,bond 的设置就基本结束了

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux网卡绑定与交换机链路聚合是一种将多个物理网卡绑定为一个逻辑接口的技术,在高负载环境下提高网络带宽和可靠性。以下是关于如何配置Linux网卡绑定和交换机链路聚合的指导: 1. Linux网卡绑定配置: a. 确保服务器上安装了所需的驱动程序和工具,如bonding模块和ifenslave b. 在/etc/modules文件中添加bonding模块:modprobe bonding c. 创建一个新的网络接口,如bond0:编辑/etc/network/interfaces文件,并添加以下行: auto bond0 iface bond0 inet static address 192.168.xxx.xxx netmask 255.255.255.0 gateway 192.168.xxx.xxx slaves eth0 eth1 bond-mode 4 bond-miimon 100 bond-downdelay 200 bond-updelay 200 bond-lacp-rate 1 bond-xmit-hash-policy layer2+3 bond-primary eth0 d. 保存文件并重启网络服务:service networking restart 2. 交换机链路聚合配置: a. 登录交换机的管理界面 b. 创建一个新的聚合组:选择一个可用的组号,并指定组的工作模式为链路聚合(LACP或者Static) c. 添加相应的物理接口到聚合组中:将服务器上用于多网卡绑定的物理接口添加到交换机的聚合组中 d. 配置组的其他参数:根据需求,可以配置链路聚合组的一些其他参数,如备用接口、链路优先级等 e. 保存并应用配置,确保交换机和服务器的配置一致 配置完成后,多个物理网卡将作为一个逻辑接口(bond0)运行,向外提供网络连接。交换机链路聚合将这些物理链路合并成一个逻辑链路,提供更高的带宽和可靠性。需要注意的是,配置过程中需要确保服务器和交换机的配置参数一致,否则可能会导致链路无法正常工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值