今天遇到一个Channel bonding的问题,先说说Channel bonding这个东西。Channel bonding使用二块或者更多的Network interfaces来组成一块,同时也提升了带宽,提供冗余。
下面就说说怎么创建一个Channel bonding interface。涉及到下面几个文件:
- /etc/sysconfig/network-scripts/ifcfg-bond0
-
/etc/sysconfig/network-scripts/ifcfg-eth0
-
/etc/sysconfig/network-scripts/ifcfg-eth1
-
/etc/modprobe.conf
ifcfg-bond0是bond0的配置文件,我的配置是这样的:
- DEVICE=bond0
-
IPADDR=10.16.65.43
-
NETMASK=255.255.248.0
-
ONBOOT=yes
-
BOOTPROTO=dhcp
-
USERCTL=no
-
BONDING_OPTS="mode=1 miimon=50"
这里需要注意的一点是BOOTPROTO的配置,这里应该和你的原始ifcfg-eth0的里面的BOOTPROTO一样。我最开始的时候在这里配错了,结果死活起不来网络!
然后就是ifcfg-eth0了,这个文件是第一块以太网卡的配置文件,一般是这样的:
- # Broadcom Corporation NetXtreme BCM5755 Gigabit Ethernet PCI Express
-
DEVICE=eth0
-
BOOTPROTO=dhcp
-
HWADDR=00:1E:0B:A3:A5:F4
-
ONBOOT=yes
需要修改成这样:
- # Broadcom Corporation NetXtreme BCM5755 Gigabit Ethernet PCI Express
-
DEVICE=eth0
-
BOOTPROTO=none
-
HWADDR=00:1E:0B:A3:A5:F4
-
ONBOOT=yes
-
MASTER=bond0
-
SLAVE=yes
-
USERCTL=no
看配置文件就明白了,这里把eth0设置成了bond0的一个SLAVE!同样的,需要设置另外一个SLAVE,可以是eth1也可以是别的,当然了随你高兴!这里是我的ifcfg-eth1:
- # Broadcom Corporation NetXtreme BCM5755 Gigabit Ethernet PCI Express
-
DEVICE=eth1
-
BOOTPROTO=none
-
HWADDR=00:1E:0B:A3:A5:F3
-
ONBOOT=yes
-
MASTER=bond0
-
SLAVE=yes
-
USERCTL=no
基本的网络配置就完成了,还有另外的一个文件需要修改!/etc/modprobe.conf!
需要说明一下的是,在RHEL5里面,是存在这个文件的!但是,在Fedora 13是没有这个文件的!不过可以手动创建^_^
加入以下内容:
如果你建立了多块bond,比如bond0,bond1,bond2,那么就要这么写:
- alias bond0 bonding
-
alias bond1 bonding
-
alias bond2 bonding
到这,所有的配置就都完成了,重启电脑,查看一下网络吧o(∩∩)o...
- [root@hp-xw8600-01 ~]# ifconfig -a
-
bond0 Link encap:Ethernet HWaddr 00:1E:0B:A3:A5:F4
-
inet addr:10.16.65.43 Bcast:10.16.71.255 Mask:255.255.248.0
-
inet6 addr: fec0:0:a10:4000:21e:bff:fea3:a5f4/64 Scope:Site
-
inet6 addr: fe80::21e:bff:fea3:a5f4/64 Scope:Link
-
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
-
RX packets:3000 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:378 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:267901 (261.6 KiB) TX bytes:51397 (50.1 KiB)
-
-
eth0 Link encap:Ethernet HWaddr 00:1E:0B:A3:A5:F4
-
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
-
RX packets:3000 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:378 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:267901 (261.6 KiB) TX bytes:51397 (50.1 KiB)
-
Interrupt:209 Memory:f3300000-f3310000
-
-
eth1 Link encap:Ethernet HWaddr 00:1E:0B:A3:A5:F4
-
UP BROADCAST SLAVE MULTICAST MTU:1500 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:1000
-
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
-
Interrupt:217 Memory:f3200000-f3210000
-
-
lo Link encap:Local Loopback
-
inet addr:127.0.0.1 Mask:255.0.0.0
-
inet6 addr: ::1/128 Scope:Host
-
UP LOOPBACK RUNNING MTU:16436 Metric:1
-
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:560 (560.0 b) TX bytes:560 (560.0 b)
-
-
sit0 Link encap:IPv6-in-IPv4
-
NOARP MTU:1480 Metric:1
-
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
-
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
-
collisions:0 txqueuelen:0
-
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
-
[root@hp-xw8600-01 ~]# cat /proc/net/bonding/bond0
-
Ethernet Channel Bonding Driver: v3.4.0-1 (October 7, 2008)
-
-
Bonding Mode: fault-tolerance (active-backup)
-
Primary Slave: None
-
Currently Active Slave: eth0
-
MII Status: up
-
MII Polling Interval (ms): 50
-
Up Delay (ms): 0
-
Down Delay (ms): 0
-
-
Slave Interface: eth0
-
MII Status: up
-
Speed: 100 Mbps
-
Duplex: full
-
Link Failure Count: 0
-
Permanent HW addr: 00:1e:0b:a3:a5:f4
-
-
Slave Interface: eth1
-
MII Status: down
-
Speed: 100 Mbps
-
Duplex: full
-
Link Failure Count: 0
-
Permanent HW addr: 00:1e:0b:a3:a5:f3
阅读(3579) | 评论(0) | 转发(0) |