日期:2014-05-16  浏览次数:20643 次

linux下多网卡绑定

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

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

                   alias bond0 bonding

                   options bonding miimon=100 mode=4

         mode0时,交换机相应端口不需要做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