Chinaunix首页 | 论坛 | 博客
  • 博客访问: 197335
  • 博文数量: 22
  • 博客积分: 1696
  • 博客等级: 上尉
  • 技术积分: 336
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-06 21:22
文章分类

全部博文(22)

文章存档

2011年(4)

2010年(18)

分类: LINUX

2010-10-28 13:54:35

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