最近在研究网口聚合,系统是centos5.5(内核是2.6.18),先根据配置好聚合口,再用iometer工具通过配置好的聚合口对磁盘进行打流量,看最终的效果如何?
配置网口聚合的时候,我选择了两种模式:balance-rr和active-backup。balance-rr模式采用的是轮转算法(round-robin),即数据包会按顺序从第一个可用的绑定网口(即该聚合口的slave)到最后一个slave中传输,此时每个slave上都会有数据流量,而active-backup模式采用的是备份算法,此时只有一个slave是激活的,只有该salve上有数据流量,当该slave有问题不能正常工作时,其他的某个slave会被激活,
linux内核文档bonding.txt如是描述这两种模式:
balance-rr or 0
Round-robin policy: Transmit packets in sequential
order from the first available slave through the
last. This mode provides load balancing and fault
tolerance.
active-backup or 1
Active-backup policy: Only one slave in the bond is
active. A different slave becomes active if, and only
if, the active slave fails. The bond's MAC address is
externally visible on only one port (network adapter)
to avoid confusing the switch.
In bonding version 2.6.2 or later, when a failover
occurs in active-backup mode, bonding will issue one
or more gratuitous ARPs on the newly active slave.
One gratuitous ARP is issued for the bonding master
interface and each VLAN interfaces configured above
it, provided that the interface has at least one IP
address configured. Gratuitous ARPs issued for VLAN
interfaces are tagged with the appropriate VLAN id.
This mode provides fault tolerance. The primary
option, documented below, affects the behavior of this
mode.
如果你想详细的了解bonding,那么这个文档无疑是最权威的,内核源码中包含了该文件,路径是kernel-source/Documentation/networking/bonding.txt。
配置bonding有好几种方式,可以通过Initscritps来实现,即配置/etc/sysconfig/network-scripts/目录下的配置文件,可以通过工具ifenslave来实现,还可以通sysfs 接口来实现,即配置/sys/class/net/下的的配置文件,使用起来很方便,还有一些其他的方法,bonding.txt中都有详细的说明。
一、 配置balance-rr模式的网口聚合
1.修改/etc/modprobe.cof,在文件的最后一行添加如下内容:
alias bond2 bonding
2.加载bonding驱动
#modprobe bonding
3.修改配置文件
在此,我使用的是Initscripts方法来配置,假如要配置的目标机器上有eth1~eth4四个业务网口,那么先进入目录/etc/sysconfig/network-scripts/:
#cd /etc/sysconfig/network-scripts/
假定要配置的聚合名称为bond2,那么新建ifcfg-bond2文件:
#touch ifcfg-bond2
添加可执行属性: