centos系统网口聚合(bonding)的配置

本文介绍了在CentOS系统中配置网口聚合(bonding)的方法,重点关注balance-rr和active-backup两种模式。balance-rr模式通过轮转算法实现负载均衡和故障容忍,而active-backup模式提供备份功能,仅有一个活动接口。配置过程包括修改配置文件、重启网络等步骤,并通过工具iometer进行流量测试,验证聚合口的有效性和模式切换。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

      最近在研究网口聚合,系统是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

    添加可执行属性:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值