Linux下Bonding技术

类别:编程语言 点击:0 评论:0 推荐:

Bonding技术

以下内容适用于:

MiracleLinux (2.4.21-9.38AXsmp)

TurboLinux Server(2.4.18-5smp和2.4.18-22smp)

Red Hat Enterprise Linux AS 3(Kernel 2.4.21-4)

 

/etc/modules.conf文件

alias bond0 bonding

alias bond1 bonding

options bond0 –o bond0 mode=0 miimon=100

options bond1 –o bond1 mode=1 miimon=200

 

/etc/sysconfig/network-scripts目录

Ifcfg-bond0 ifcfg-bond1两个文件

Ifcfg-eth0 ifcfg-eth1两个文件

# ifcfg-bond1文件内容

DEVICE=bond1

BOOTPROTO=static

BROADCAST=192.168.0.255

IPADDR=192.168.0.2

NETMASK=255.255.255.0

NETWORK=192.168.0.0

ONBOOT=yes

TYPE=Ethernet

 

# ifcfg-eth1文件内容

DEVICE=eth1

BOOTPROTO=static

BROADCAST=192.168.0.255

HWADDR=00:07:E9:1A:FA:B9

IPADDR=192.168.0.112

NETMASK=255.255.255.0

NETWORK=192.168.0.0

ONBOOT=yes

TYPE=Ethernet

MASTER=bond1

SLAVE=yes

 

Bonding信息文件:

/proc/net/bond0/info

/proc/net/bond1/info

….

/proc/net/bondn/info

 

[root@xxx root]# cat /proc/net/bond1/info

bonding.c:v2.2.14 (June 30, 2003)

 

Bonding Mode: fault-tolerance (active-backup)

Currently Active Slave: eth1

MII Status: up

MII Polling Interval (ms): 0

Up Delay (ms): 0

Down Delay (ms): 0

Multicast Mode: all slaves

 

Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:07:e9:1a:fa:b9

[root@xxx root]#

 

系统加载bonding模块后执行lsmod命令结果:

[root@xxx root]# lsmod | sort

bond0                  77712   2

bond1                  77712   2

cdrom                  34176   0  (autoclean) [ide-cd]

e1000                  79488   1

ext3                  100584   2

floppy                 64112   0  (autoclean)

hid                    22628   0  (unused)

ide-cd                 36192   0  (autoclean)

input                   6432   0  [keybdev mousedev hid]

jbd                    65880   2  [ext3]

keybdev                 2976   0  (unused)

microcode               7360   0  (autoclean)

Module                  Size  Used by    Not tainted

mousedev                5912   1

soundcore               8100   0  (autoclean)

usbcore                92576   1  [hid usb-ohci]

usb-ohci               27912   0  (unused)

[root@xxx root]#

 

  

以下内容适用于Suse 9 (Kernel 2.6) [特殊]

只需要创建文件/etc/sysconfig/network/ifcfg-bond0即可,内容如下:

# suse 9 kernel 2.6 ifcfg-bond0文件内容

BOOTPROTO='static'

IPADDR='192.168.0.1'

NETMASK='255.255.255.0'

STARTMODE='onboot'

BONDING_MASTER='yes'

BONDING_MODULE_OPTS='mode=1 miimon=200'

BONDING_SLAVE0='eth1'

BONDING_SLAVE1='eth2'

 

 

对于其它的Linux,内核版本2.6以上

[和标准2.4一样]

需要将alias和options从/etc/modules.conf转移到/etc/modprobe.conf即可。

另/proc/net/bond0/info文件变更为/proc/net/bonding/bond0文件中

 
以下内容适用于Turbolinux Enterprise Server 8 powered by UnitedLinux  Kernel 2.4.21-241xxx,

Ifcfg-bond0等文件存放在/etc/sysconfig/network/目录下

 

例: [来源于HP技术支持网站]

United Linux 1.0/SuSE8

 

#vi /etc/modules.conf
  alias bond0 bonding
  options bond0 miimon=100 mode=1
 
#vi /etc/sysconfig/network/ifcfg-bond0
  DEVICE=bond0
  IPADDR=192.168.10.1
  NETMASK=255.255.255.0
  NETWORK=192.168.10.0
  BROADCAST=192.168.10.255
  ONBOOT=yes
  BOOTPROTO=none
  USERCTL=no
 
#vi /etc/sysconfig/network/ifcfg-eth0
  DEVICE=eth0
  USERCTL=no
  ONBOOT=yes
  MASTER=bond0
  SLAVE=yes
  BOOTPROTO=none
 
#vi /etc/sysconfig/network/ifcfg-eth1
  DEVICE=eth1
  USERCTL=no
  ONBOOT=yes
  MASTER=bond0
  SLAVE=yes
  BOOTPROTO=none
 
做成以下启动脚本
  #!/bin/sh
  /sbin/ifconfig bond0 192.168.10.1 netmask 255.255.255.0 broadcast 192.168.10.255 up
  /sbin/ifenslave bond0 eth0
  /sbin/ifenslave bond0 eth1
 
#shutdown -r now
 
#ifconfig -a
 
#cat /proc/net/bond0/info
   Bonding Mode: active-backup
   Currently Active Slave: eth0
   MII Status: up
   MII Polling Interval (ms): 100
   Up Delay (ms): 0
   Down Delay (ms): 0
   Slave Interface: eth1
   MII Status: up
   Link Failure Count: 0
   Slave Interface: eth0
   MII Status: up
   Link Failure Count: 0
#
 

 

本文地址:http://com.8s8s.com/it/it23726.htm