1.  RHEL4多bond配置

    系统版本:Red Hat Enterprise Linux AS release 4 (Nahant Update 6)

    网卡数量:4块

添加两个bond配置文件(以bond0为例):

[root@localhost~]# cd /etc/sysconfig/network-scripts/

[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0

[root@localhostnetwork-scripts]# vim ifcfg-bond0

DEVICE=bond0/bond1

BOOTPROTO=static

IPADDR=192.168.14.70

NETMASK=255.255.0.0

GATEWAY=192.168.0.1

ONBOOT=yes


修改网卡配置文件(以eth0为例):

[root@localhost network-scripts]#vim ifcfg-eth0

DEVICE=eth0/ethX

BOOTPROTO=static

HWADDR=52:54:00:9A:C5:BD(防止网卡飘移,可注销)

ONBOOT=yes

MASTER=bond0/bond1

SLAVE=yes


修改内核模块配置文件:

[root@localhost ~]# vim/etc/modprobe.conf

添加:

alias bond0 bonding

alias bond1 bonding

options bonding mode=1 miimon=100 max_bonds=2

重启网卡:

[root@localhost ~]# service network restart

查看bond是否加载成功(以bond0为例):

[root@localhost ~]# cat /proc/net/bonding/bond0

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


Bonding Mode: fault-tolerance (active-backup)

Primary Slave: None

Currently Active Slave: eth0--------目前bond0运行在eth0上

MII Status: up

MII Polling Interval (ms): 100

Up Delay (ms): 0

Down Delay (ms): 0


Slave Interface: eth0

MII Status: up--------------------网卡在bond中的状态

Link Failure Count: 0

Permanent HW addr: 52:54:00:9a:c5:bd


Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 52:54:00:5c:d8:0f

测试:

通过手动down同一bond中的一块网卡,查看是否作切换,使用命令:ping IP

2、RHEL5多bond配置

        系统版本:Red Hat Enterprise Linux Server release 5.5 (Tikanga)

        网卡数量:4块

添加两个bond配置文件(以bond0为例):

[root@localhost ~]# cd/etc/sysconfig/network-scripts/

[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0

[root@localhostnetwork-scripts]# vim ifcfg-bond0

DEVICE=bond0/bond1

BOOTPROTO=static

ONBOOT=yes

TYPE=Bond

IPADDR=192.168.15.3

NETMASK=255.255.0.0


修改网卡配置文件(以eth0为例):

[root@localhost network-scripts]#vim ifcfg-eth0

DEVICE=eth0/ethX

BOOTPROTO=none

ONBOOT=yes

MASTER=bond0/bond1

SLAVE=yes

修改内核模块配置文件:

[root@localhost ~]# vim /etc/modprobe.conf

添加:

alias bond0 bonding

alias bond1 bonding

options bondingmode=1 miimon=100 max_bonds=2

查看bond是否加载成功、测试请参考RHEL4多bond配置操作

3、RHEL6多bond配置

      系统版本:Red HatEnterprise Linux Server release 6.3 (Santiago)

        网卡数量:4块

添加两个bond配置文件(以bond0为例):

[root@localhost ~]# cd/etc/sysconfig/network-scripts/

[root@localhostnetwork-scripts]# cp ifcfg-eth0 ifcfg-bond0

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

DEVICE="bond0"/bond1

BOOTPROTO="static"

ONBOOT="yes"

TYPE="Bond"

NM_CONTROLLED="no"

IPADDR="192.168.15.1"

NETMASK="255.255.0.0"

BONDING_MASTER="yes"

BONDING_OPTS="mode=1 miimon=100"


RHEL6默认支持如RHEL5、4那样将bond写入加载模块的文件,但标准方法只需添加以上带边框的两个参数在bond配置文件中,所以/etc/modprobe.conf需要手动创建。

修改网卡配置文件(以eth0为例):

DEVICE="eth0"/ethX

BOOTPROTO="none"

HWADDR="52:54:00:9D:F5:4F"

ONBOOT="yes"

UUID="531f548f-c4e8-4cb1-a39b-86732a665a95"

MASTER=bond0

SLAVE="yes"


查看bond是否加载成功、测试请参考RHEL4多bond配置操作

拓展:

millmon=100,表示每100ms监测一次链路链接状态。

Linux多网卡bond常用的有三种:

mode=0:平衡负载模式,有自动备援,但需要”Switch”支援及设定。

mode=1:自动备援模式,其中一条线若断线,其他线路将会自动备援。

mode=6:平衡负载模式,有自动备援,不必”Switch”支援及设定。

RHEL6.4开始高可用集群支持模块012

mode=2:平衡策略模式,基于指定的传输HASH策略传输数据包。

 

将链路状态监测配置为arp请求监测:

当负载均衡发生主备切换时,主网卡向原来的主负载均衡发送arp请求,由于floating-ip已经漂移到新的主设备上,原来的主设备不会回应服务器的arp请求,服务器arp请求超时后,主备网卡发生切换。服务器双网卡绑定检测方式更改如下:

RHEL4\5在/etc/modprobe.conf文件中添加

options bonding mode=1 arp_interval=60 arp_ip_target=IP

arp_interval=100    表示100毫秒发送一次arp请求

arp_ip_target=IP    表示主网卡发出arp请求IP

RHEL6中直接在网卡配置文件添加:

BONDING_MASTER=yes

BONDING_OPTS="mode=1arp_interval=100 arp_ip_target=IP"