分类: 系统运维
2009-02-10 11:50:05
一 系统是否支持bond
# uname -a
Linux xk-6-50-a8.bta.net.cn 2.6.18-92.1.6.el5 #1 SMP Wed Jun 25 13:45:47 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
# ll /lib/modules/2.6.18-92.1.6.el5/kernel/drivers/net/bonding/
-rwxr--r-- 1 root root 168104 Jun 26 2008 bonding.ko
二 Bond配置
#cat /etc/modprobe.conf
alias bond0 bonding #定义bonding别名
options bond0 mode=balance-rr use_carrier=1 miimon=10 #设置bond均衡模式
【mode算法有很多,详见BOND官方文档】
修改 /etc/sysconfig/network-scripts下面的
手工添加 ifcfg-bond0配置文件
# vi ifcfg-bond0 #聚合虚拟网卡
DEVICE=bond0
BOOTPROTO=none
TYPE=Ethernet
ONBOOT=yes
IPADDR=202.10x.xx.xx #bond ip地址
NETMASK=255.255.255.0 #bond 掩码
GATEWAY=202.10x.x.1 #屏蔽了网关
# vi ifcfg-eth4 #聚合物理网卡1 [该例子使用了ETH4]
DEVICE=eth4
HWADDR=00:1B:21:20:16:48
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
# vi ifcfg-eth5 #聚合物理网卡2 [该例子使用了ETH5]
DEVICE=eth5
HWADDR=00:1B:21:20:16:4D
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
三 上述配置完毕后 重启系统
# reboot
四 查看bond状态
设备重启后检查bond
# lsmod |grep bon #内核是否已经加载
bonding 121121 0
cat /proc/net/bonding/bond0 #bond工作状态
Ethernet Channel Bonding Driver: v3.2.4 (January 28, 2008)
Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 10
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth4
MII Status: up
Permanent HW addr: 00:1b:21:20:16:48
Slave Interface: eth5
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:1b:21:20:16:4d
# ifconfig #系统网卡工作状态
bond0 Link encap:Ethernet HWaddr 00:1B:21:20:16:48
inet addr:202.10x.x.x Bcast:202.10x.xx.xx Mask:255.255.255.0
inet6 addr: fe80::21b:21ff:fe20:1648/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:49515 errors:0 dropped:0 overruns:0 frame:0
TX packets:20339957 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3215189 (3.0 MiB) TX bytes:30249261388 (28.1 GiB)
eth4 Link encap:Ethernet HWaddr 00:1B:21:20:16:48
inet6 addr: fe80::21b:21ff:fe20:1648/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:10172747 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2550 (2.4 KiB) TX bytes:15128508431 (14.0 GiB)
Memory:f96e0000-f9700000
eth5 Link encap:Ethernet HWaddr 00:1B:21:20:16:48
inet6 addr: fe80::21b:21ff:fe20:1648/64 Scope:Link
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
RX packets:49503 errors:0 dropped:0 overruns:0 frame:0
TX packets:10167230 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3212639 (3.0 MiB) TX bytes:15120757893 (14.0 GiB)
Memory:f9bc0000-f9be0000
网卡的speed BASE状态
# ethtool eth5
Settings for eth5:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
# route –n 系统路由状态[主要观察默认网关]
Destination Gateway Genmask Flags Metric Ref Use Iface
202.10x.xx.xx 0.0.0.0 255.255.255.0 U 0 0 0 bond0
0.0.0.0 202.10x.x.xx 0.0.0.0 UG 0 0 0 bond0
五 压力测试bond
本人在BOND SERVER上面配置了SQUID 通过对其请求来观察BOND是否可以达到汇聚
经过测试得出
# sar -n 'DEV' 1 10000 |grep -E 'IFACE|eth4|eth5|bond0'
#bond生效后的网络流量状态
11:18:36 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
11:18:37 AM eth4 94899.00 91759.00 7538991.00 122889931.00 0.00 0.00 0.00
11:18:37 AM eth5 89534.00 91466.00 7077817.00 122931690.00 0.00 0.00 0.00
11:18:37 AM bond0 184433.00 183225.00 14616808.00 245821621.00 0.00 0.00 0.00
11:18:37 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
11:18:38 AM eth4 87027.00 91544.00 6932208.00 122952488.00 0.00 0.00 0.00
11:18:38 AM eth5 97895.00 91427.00 7823410.00 122933188.00 0.00 0.00 0.00
11:18:38 AM bond0 184922.00 182971.00 14755618.00 245885676.00 0.00 0.00 0.00
11:18:38 AM IFACE rxpck/s txpck/s rxbyt/s txbyt/s rxcmp/s txcmp/s rxmcst/s
11:18:39 AM eth4 90615.00 91626.00 7177923.00 122938161.00 0.00 0.00 0.00
11:18:39 AM eth5 94419.00 91482.00 7534606.00 122956906.00 0.00 0.00 0.00
11:18:39 AM bond0 185034.00 183108.00 14712529.00 245895067.00 0.00 0.00 0.00
245821621.00 * 8 / 1024 /1024 = 1875Mbps 记住流量单位是BIT不是BYTE
后记:网上配置bond的文章很多,测试文章也很多,之所以还打算写一篇的原因是,大家没有环境去测试1G以上的BOND效果,所以借此机会整理了下,发表出来,希望可以作为大家的参考。如有遗漏或不足之处,请大家指出,谢谢
COPYRIGHT BY IORI YANG
STAY IN SINA
11:50 10TH FEB 2009