Chinaunix首页 | 论坛 | 博客
  • 博客访问: 239561
  • 博文数量: 19
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 435
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-15 15:40
文章分类

全部博文(19)

文章存档

2011年(1)

2010年(2)

2009年(5)

2008年(11)

我的朋友

分类: 系统运维

2009-02-10 11:50:05

最近公司为了替换线上陈旧设备,找来一些超强的山寨SERVER进行测试。以便为了用一台机器尽可能多的替代线上server,用以实现一骑当千的功效。并且可以减少管理设备数量,方便维护。
 
硬件环境
山寨server
 2颗cpu 8核【Intel(R) Xeon(R) CPU  X5560  @ 2.80GHz】
       12G内存 
       harddisk 300 GB*8块【希捷SAS】 
       6块网卡 1000Mbps【igb】
 
交换机  不详   

os   CentOS release 5.2   2.6.18-92.1.6.el5 x86_64 GNU/Linux
 
起初我们压力测试squid可以达到单台1.5w并发响应,随后发现该设备的网卡跑满了,但设备硬件资源没有任何瓶颈,全部瓶颈在于网卡1000M限制。随后我们决定使用流行的bond来实施——端口的汇聚。
 
架构如下:
交换机端  使用超成熟的port_channel【网络部分不是我负责,不过该配置很简单,一GOOGLE一大把,这里不再详述】
SERVER端 使用较成熟的BOND模式【注意前提你必须有2块网卡且网卡型号和speed保持一致性】
 
 
详述SERVER端的BOND0配置
 

     系统是否支持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

 

基本上来说现在大家都在使用LINUX 2.6内核的os了 所以BOND已经默认装入内核 大家不用担心自己的LINUX不支持【貌似2.4开始就已经支持了】
 

      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

Link Failure Count: 0

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

阅读(1717) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

pojo8982009-02-10 14:13:52

顶!!!!!