Linux下多网卡绑定
0
无    2020-09-02 11:59:33    0    0
myron

Centos7下多网卡绑定


nmcli connection add type bond ifname eth0 mode 4

nmcli connection add type bond-slave ifname em1 master eth0

nmcli connection add type bond-slave ifname em2 master eth0

————————————————————————————————————————————
http://www.cnblogs.com/liwanggui/p/6807212.html


# 生成bond配置文件
[root@localhost network-scripts]# nmcli connection add type bond ifname bond0 mode 4
# 将网卡`eno33554960`与`eno50332184`绑定到bond0
[root@localhost network-scripts]# nmcli connection add type bond-slave ifname eno33554960 master bond0
[root@localhost network-scripts]# nmcli connection add type bond-slave ifname eno50332184 master bond0
# 查看生成的配置文件
[root@localhost network-scripts]# ls ifcfg-bond-*
ifcfg-bond-bond0 ifcfg-bond-slave-eno33554960 ifcfg-bond-slave-eno50332184


_____________________________________________________________________________________

假定将eth0,eth1,eth2,eth3绑定成bond0, 步骤如下:
(1) #Linux VI 命令/etc/modprobe.conf, 添加如下2行:
alias bond0 bonding
options bonding miimon=100 mode=4
当mode=0时,交换机相应端口不需要做trunk,但是从节点上ping网关(192.*.*.*)有较大的延时。解决此问题的办法是把mode改成4,同时配置交换机相应端口开启链路聚合并捆绑为trunk。
www.2cto.com
在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
www.2cto.com
(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 已经生效
www.2cto.com
然后在交换机(这里的交换机是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 已经生效
www.2cto.com
在modprobe.conf文件中,
miimon参数用来监测网卡物理连接,建议至少设为100
mode参数用来设置绑定模式
0 负载均衡(round robin策略)
1 active/backup模式,同一时间只有一块网卡使用。
2 负载均衡(xor算法)
3 广播模式
4 802.3ad模式,lagp协议,带宽翻倍。
模式不能写错

______________________________________________________________

Linux 系统
[root@lab]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
BOOTPROTO=none
IPADDR=172.16.1.248
NETMASK=255.255.255.0
GATEWAY=172.16.1.1
TYPE=Ethernet
BONDING_OPTS="mode=4 miimon=100"
[root@lab]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
[root@lab]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes
[root@lab]# cat /etc/modprobe.d/bond0.conf
alias bond0 bonding

____________________________________________________________

5. 交换机配置
====================================

在本节中,"交换机(switch)"指被bond设备直接连接的系统(也就是说,另一端电缆连接着的),这可能是一个专职的交换机设备,也可能是其它的系统(比如,另一个运行Linux的系统)。

active-backup、balance-tlb和balance-alb模式不需要对交换机做任何的配置。

802.3ad模式需要交换机有对应的配置为802.3ad聚合的端口,具体的配置方法因交换机类型而异,比如,Cisco 3550系列交换机要求对应的端口首先必须被分组在一个单独的etherchannel实例,然后这个etherchannel设置为"lacp"模式已 启用802.3ad(取代标准EtherChannel)。

balance-rr、balance-xor和broadcast模式通常需要交换机对应的端口被分组在一起,不同的交换机对分组有着不同的命名,可能 会被叫做“etherchannel”(比如上文的Cisco示例),或者叫做“trunk group”,或者其他类似的命令。对于这些模式,每个交换机也会有它自己的针对到bond的传输策略的配置选项。典型的选择包括对每个MAC地址或者 IP地址进行XOR操作,两端的传输策略不一定完全一致。对这三种模式,bonding模式会针对一个EtherChannel组选择一种传输策略;所有 这三种模式都会和另一个EtherChannel组进行互操作。

----------------------------------------------------------------------------------------
The balance-rr, balance-xor and broadcast modes generally
require that the switch have the appropriate ports grouped together.
The nomenclature for such a group differs between switches, it may be
called an "etherchannel" (as in the Cisco example, above), a "trunk
group" or some other similar variation. For these modes, each switch
will also have its own configuration options for the switch's transmit
policy to the bond. Typical choices include XOR of either the MAC or
IP addresses. The transmit policy of the two peers does not need to
match. For these three modes, the bonding mode really selects a
transmit policy for an EtherChannel group; all three will interoperate
with another EtherChannel group.
----------------------------------------------------------------------------------------


_____________________________________________________________________________________

Info
文档导航