yujin2010good
作者yujin2010good·2019-07-17 11:59
系统工程师·大型零售巨头

linux下多网卡绑定

字数 4119阅读 1399评论 1赞 2

假定将eth0,eth1,eth2,eth3绑定成bond0,步骤如下:

(1) #vi /etc/modprobe.conf, 添加如下2行:

alias bond0 bonding

options bonding miimon=100 mode=4

当mode=0时,交换机相应端口不需要做trunk,但是从节点上ping网关(192...*)有较大的延时。解决此问题的办法是把mode改成4,同时配置交换机相应端口开启链路聚合并捆绑为trunk。

在modprobe.conf文件中,

miimon参数用来监测网卡物理连接,建议至少设为100

mode参数用来设置绑定模式

0 负载均衡(round robin策略)

1 active/backup模式,同一时间只有一块网卡使用。

2 负载均衡(xor算法)

3 广播模式

4 802.3ad模式,lagp协议,带宽翻倍。

模式不能写错

这里很容易出现不稳定的情况,多半是这里模式选择错了,所以在实施的时候需要小心,把模式确定了,然后在动手。

(2)修改/etc/sysconfig/network-scripts/目录下的ifcfg-bond0, ifcfg-eth0, ifcfg-eth1,ifcfg-eth2,ifcfg-eth3. 具体内容如下:
[root@io102 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@io102 network-scripts]# cat ifcfg-bond0
DEVICE=bond0
BOOTPROTE=static
ONBOOT=yes
IPADDR=192...*
NETMASK=255.255.255.0
USERTCL=no
GATEWAY=192...*
[root@io102 network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes
[root@io102 network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes
[root@io102 network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes
[root@io102 network-scripts]# cat ifcfg-eth3
DEVICE=eth3
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
USERTCL=no
MASTER=bond0
SLAVE=yes

(3)查看bond0的状态

[root@io102 ~]# more /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v2.6.3-rh (June 8, 2005)

Bonding Mode: IEEE 802.3ad Dynamic link aggregation

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0

802.3ad info

LACP rate: slow

Active Aggregator Info:

Aggregator ID: 1

Number of ports: 4

Actor Key: 17

Partner Key: 480

Partner Mac Address: 00:12:f2:cd:68:00

Slave Interface: eth0

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:1e:0b:73:56:26

Aggregator ID: 1

Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:1e:0b:73:56:a2

Aggregator ID: 1

Slave Interface: eth2

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:1e:0b:d5:34:d2

Aggregator ID: 1

Slave Interface: eth3

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:1e:0b:d5:34:d0

Aggregator ID: 1

然后在交换机(这里的交换机是Foundry)端做TRUNK
将同一台服务器的多个网卡捆绑成一条逻辑的线路来使用,提高服务器与交换机之间的带宽,并且能够负载均衡多个网卡上的流量,以及多个网卡之间的冗余当其中一个网卡坏了其它的网卡会平分坏网卡上的流量 ,并不影响服务器与交换机之间的数据转发。注 如果交换机配置为trunk 那么服务器段也要做相应的配置 trunk 才能被正确的使用
BR-telnet@YJY_SX_1600#show trunk
Configured trunks:
Trunk ID: 897
Hw Trunk ID: 6
Ports_Configured: 4
Primary Port Monitored: Jointly

Ports 15/1 15/2 15/3 15/4
Port Names none none none none
Port_Status enable enable enable enable
Monitor off off off off
Rx Mirr Port N/A N/A N/A N/A
Tx Mirr Port N/A N/A N/A N/A
Monitor Dir N/A N/A N/A N/A
Trunk ID: 901
Hw Trunk ID: 11
Ports_Configured: 4
Primary Port Monitored: Jointly
Ports 15/5 15/6 15/7 15/8
Port Names none none none none
Port_Status enable enable enable enable
Monitor off off off off
Rx Mirr Port N/A N/A N/A N/A
Tx Mirr Port N/A N/A N/A N/A
Monitor Dir N/A N/A N/A N/A
查看如上的红色标注信息 端口状态是enable 本组trunk 包括 15/5 15/6 15/7 15/8 这4个端口 本组trunk 已经生效

然后在交换机(这里的交换机是Foundry)端做TRUNK

将同一台服务器的多个网卡捆绑成一条逻辑的线路来使用,提高服务器与交换机之间的带宽,并且能够负载均衡多个网卡上的流量,以及多个网卡之间的冗余当其中一个网卡坏了其它的网卡会平分坏网卡上的流量,并不影响服务器与交换机之间的数据转发。注 如果交换机配置为trunk 那么服务器段也要做相应的配置 trunk 才能被正确的使用

BR-telnet@YJY_SX_1600#show trunk

Configured trunks:

Trunk ID: 897

Hw Trunk ID: 6

Ports_Configured: 4

Primary Port Monitored: Jointly

Ports 15/1 15/2 15/3 15/4

Port Names none none none none

Port_Status enable enable enable enable

Monitor off off off off

Rx Mirr Port N/A N/A N/A N/A

Tx Mirr Port N/A N/A N/A N/A

Monitor Dir N/A N/A N/A N/A

Trunk ID: 901

Hw Trunk ID: 11

Ports_Configured: 4

Primary Port Monitored: Jointly

Ports 15/5 15/6 15/7 15/8

Port Names none none none none

Port_Status enable enable enable enable

Monitor off off off off

Rx Mirr Port N/A N/A N/A N/A

Tx Mirr Port N/A N/A N/A N/A

Monitor Dir N/A N/A N/A N/A

查看如上的红色标注信息 端口状态是enable 本组trunk 包括 15/5 15/6 15/7 15/8 这4个端口 本组trunk 已经生效

在modprobe.conf文件中,

miimon参数用来监测网卡物理连接,建议至少设为100

mode参数用来设置绑定模式

0负载均衡(round robin策略)

1 active/backup模式,同一时间只有一块网卡使用。

2负载均衡(xor算法)

3广播模式

4 802.3ad模式,lagp协议,带宽翻倍。

模式不能写错。

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

2

添加新评论1 条评论

liwei430074liwei430074软件开发工程师武汉公司
2019-07-21 08:41
资料不错。
Ctrl+Enter 发表

作者其他文章

相关文章

相关问题

相关资料

X社区推广