Archive

Archive for the ‘工具介绍’ Category

hwconfig查看硬件信息

February 28th, 2012 21 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: hwconfig查看硬件信息

最近经常要测试新硬件,了解硬件的具体型号和参数就非常重要,过去经常透过lspci, dmidecode, dmesg, ethtool, lshal, megacli等命令和各种/proc信息来了解,需要对这些工具很熟悉, 貌似比较不方便和准确。

今天看到某同学用的hwconfig感觉信息很专业,推荐给大家。这里可以下载, 感谢微博@frostwatcher同学.

hwconfig透过收集上面提到的各种信息, 然后根据wiki或者厂家公布的设备识别码, 进一步加工,给用户一个直观的信息.

不废话,效果如下:

$ uname -r
2.6.18-164.el5
$ hwconfig  -h
usage:  hwconfig [-dhnv] [-t timeout] [-r file] [-x file] [-o file]
        -d  show debugging information
        -h  show usage
        -n  don't break output lines
        -o  write output to file (- for stdout)
        -r  write raw source to file (- for stdout)
        -t  abort after timeout seconds
        -v  show version
        -x  write xml to file (- for stdout)
##简约模式
$ sudo hwconfig   
hwconfig: warning: could not run megarc; please yinst megarc
Summary:        Huawei Technologies Tecal RH2285, 2 x Xeon E5620 2.40GHz, 23.5GB / 24GB 1066MHz
System:         Huawei Technologies Tecal RH2285 (Huawei Technologies BC11BTSA)
Processors:     2 x Xeon E5620 2.40GHz 133MHz FSB (16 cores)
Memory:         23.5GB / 24GB 1066MHz == 6 x 4GB, 6 x empty
Disk:           sda (megaraid_sas0): 107GB (38%) JBOD == 1 x LSI-MegaRAID-SAS-RMB
Disk:           sdb (megaraid_sas0): 5.9TB (1%) JBOD == 1 x LSI-MegaRAID-SAS-RMB
Disk-Control:   megaraid_sas0: LSI Logic / Symbios Logic MegaRAID SAS 1078
Disk-Control:   ata_piix0: Intel 82801JI (ICH10 Family) 4 port SATA IDE Controller
Disk-Control:   ata_piix1: Intel 82801JI (ICH10 Family) 2 port SATA IDE Controller
Network:        host5 (bnx2-1): Broadcom NetXtreme II BCM5709 Gigabit Ethernet
Network:        host6 (bnx2-0): Broadcom NetXtreme II BCM5709 Gigabit Ethernet
Network:        eth0 (bnx2): 08:19:a6:24:3c:05, 1000Mb/s <full-duplex>
Network:        eth1 (bnx2): 08:19:a6:24:3c:05, 1000Mb/s <full-duplex>
OS:             RHEL Server 5.4 (Tikanga), Linux 2.6.18-164.el5 x86_64, 64-bit
BIOS:           AMI CTSAV035 12/07/2010
Hostname:       xxxxxx

##这个是非常详细的模式, 了解到各个设备的细节.
$ sudo hwconfig -x cfg.xml
$ less cfg.xml
<system code_version="1.16.7" hostname="dr4000" timestamp="1331966816" xml_version="1.0.1">
  <base_board manufacturer="Dell Inc." model="084YMW" serial="..CN137401C800C9." version="A05" />
  <bios date="10/21/2011" manufacturer="Dell Inc." pretty="Dell 1.9.0 10/21/2011" rev="1.9" version="1.9.0" />
  <chipsets summary="Intel 5500 IOH-24D B3 (Tylersburg), 82801JIR A0 (ICH10R)">
    <chipset handle="56" model="5500 IOH-24D" name="Tylersburg" pci="00:00.0" pci_handle="1" stepping="B3" type="Northbridge" vendor="Intel" />
    <chipset handle="57" model="82801JIR" name="ICH10R" pci="00:1f.0" pci_handle="19" stepping="A0" type="Southbridge" vendor="Intel" />
  </chipsets>
...
 <volume controller="scsi0" drive_write_cache="default" handle="75" name="sda" raid="RAID-0" read_ahead="adaptive" size="598879502336" spans="1" status="ok" stripe="65536">
      <drives>
        <drive>66</drive>
        <drive>67</drive>
      </drives>
      <read_cache enable="0" />
      <write_cache enable="0" policy="write-back" />
    </volume>
  </storage>
  <system manufacturer="Dell Inc." model="Dell DR4000" pretty="Dell DR4000" serial="8MCBB3X" uuid="4C4C4544-004D-4310-8042-B8C04F423358" version="" />
</system>

看着信息还是很专业的,结果微博上有同学反映是个脚本,我看了下原来hwconfig真的是个脚本:

#!/usr/bin/perl -w

# $Id$

$ENV{PATH} = "/etc/bin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/sbin:/home/opt:/opt/MegaRAID/MegaCli:/usr/StorMan";

use strict 'vars';
use Getopt::Std;
use POSIX;
...
$ cat `which hwconfig `|wc -l    
9101

挺佩服这帮人的,脚本也能有这样的耐心,写这么长。

祝大家玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍 Tags:

blktrace未公开选项网络保存截取数据

February 28th, 2012 Comments off

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: blktrace未公开选项网络保存截取数据

我们透过blktrace来观察io行为的时候,第一件事情需要选择目标设备,以便分析该设备的io行为。具体使用可以参考我之前写的几篇:这里 这里 这里

blktrace分为内核部分和应用部分,应用部分收到我们要捕捉的设备名单,传给内核。内核分布在block层的各个tracepoint就会开始工作,把相关的数据透过relayfs传递到blktrace的应用部分,应用部分把这些数据记到磁盘,以便后续分析。架构参见下图:

从man blktrace中可以看到:

blktrace stores the extracted data into files stored in the local directory. The format of the file names is (by default) device.blktrace.cpu, where device is the base device name (e.g, if we are tracing /dev/sda, the base device name would be sda); and cpu identifies a CPU for the event stream

这时候问题就来了,如果我的机器只有一个设备,那么blktrace存数据文件这个动作就会影响到我们正常的IO行为。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍 Tags:

MYSQL数据库网卡软中断不平衡问题及解决方案

January 16th, 2012 30 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: MYSQL数据库网卡软中断不平衡问题及解决方案

最近公司在MySQL的数据库上由于采用了高速的如PCIe卡以及大内存,去年在压力测试的时候突然发现数据库的流量可以把一个千M网卡压满了。随着数据库的优化,现在流量可以达到150M,所以我们采用了双网卡,在交换机上绑定,做LB的方式,提高系统的吞吐量。

但是在最近压测试的一个数据库中,mpstat发现其中一个核的CPU被软中断耗尽:

Mysql QPS 2W左右

——– —–load-avg—- —cpu-usage— —swap— -QPS- -TPS- -Hit%-
time | 1m 5m 15m |usr sys idl iow| si so| ins upd del sel iud| lor hit|
13:43:46| 0.00 0.00 0.00| 67 27 3 3| 0 0| 0 0 0 0 0| 0 100.00|
13:43:47| 0.00 0.00 0.00| 30 10 60 0| 0 0| 0 0 0 19281 0| 326839 100.00|
13:43:48| 0.00 0.00 0.00| 28 10 63 0| 0 0| 0 0 0 19083 0| 323377 100.00|
13:43:49| 0.00 0.00 0.00| 28 10 63 0| 0 0| 0 0 0 19482 0| 330185 100.00|
13:43:50| 0.00 0.00 0.00| 26 9 65 0| 0 0| 0 0 0 19379 0| 328575 100.00|
13:43:51| 0.00 0.00 0.00| 27 9 64 0| 0 0| 0 0 0 19723 0| 334378 100.00|

mpstat -P ALL 1说:

针对这个问题,我们利用工具,特别是systemtap, 一步步来调查和解决问题。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

systemtap如何跟踪libc.so

January 12th, 2012 22 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: systemtap如何跟踪libc.so

下午和周忱同学折腾复杂程序的内存泄漏问题,用了valgrind, gogle perftools等工具都不大好用,很容易把应用程序搞死,于是打算用systemtap来在libc.so层面了解内存的使用情况。主要思路就是看malloc/realloc和free的调用次数的平衡。

首先准备下环境,系统是标准的RHEL 5u4:

$ uname -r
2.6.18-164.el5

$ stap -V
SystemTap translator/driver (version 1.3/0.137 non-git sources)
Copyright (C) 2005-2010 Red Hat, Inc. and others
This is free software; see the source for copying conditions.
enabled features: LIBRPM LIBSQLITE3 NSS BOOST_SHARED_PTR TR1_UNORDERED_MAP
$stap -L  'kernel.function("printk")'
kernel.function("printk@kernel/printk.c:533") $fmt:char const* $args:va_list

$ stap -L  'process("/lib64/libc.so.6").function("malloc")'
Missing separate debuginfos, use: debuginfo-install glibc-2.5-42.x86_64 

内核的符号是OK的,glibc没有安装符号。系统提示用 debuginfo-install glibc-2.5-42.x86_64 命令安装符号信息,但是RHEL 5不交钱不能用这个服务的,只能自己下载包安装。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: 工具介绍, 调优 Tags: ,

给你的Linux系统上点stress

January 9th, 2012 Comments off

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: 给你的Linux系统上点stress

《debug hacks》 这本书介绍了非常多的调试手段和工具, 其中提到了stress这个简单的压力测试工具,在我们的日常工作中很有用。利用它可以给我们的系统施加CPU,内存,IO和磁盘的压力,在模拟极端场景给应用系统造成的压力方面很有帮助。

主页见这里:http://weather.ou.edu/~apw/projects/stress/
这里还有一篇介绍如何使用的博客。

stress is a deliberately simple workload generator for POSIX systems. It imposes a configurable amount of CPU, memory, I/O, and disk stress on the system. It is written in C, and is free software licensed under the GPLv2.

这个stress实现非常的简单,所有的功能在一个.c文件里面实现, 系统运行的时候会fork多个子进程,分别进行CPU,内存,IO方面的折磨。
Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍 Tags:

fio配合cgroup测试存储设备IOPS分配

December 28th, 2011 Comments off

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: fio配合cgroup测试存储设备IOPS分配

随着包括存储设备在内服务器的能力越来越高,特别是用上了PCIe存储卡后,IOPS能力通常有10几万,马上过剩。在这种情况下,一台服务器可以干很多事情,在上面跑很多服务。那么如何保证系统的服务质量是个很重要的事情了。

我们在下来的的项目中倾向于用cgroup来做资源的隔离和限制,原因是cgroup的开销很小,而且很易用。cgroup 可以参考这里

我们特别关心cgroup的blkio子模块,他有2种限制模式:
1. throttle,限制每个进程能使用的IOPS或者吞吐量。
2. weight,现在每个进程能使用的IOPS的能力的比例,必须通过CFQ调度器来实现。
文档和具体的参数可以看上面提到的cgroup文档。

Read more…

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍, 调优 Tags: ,

slabtop简单的用途

December 15th, 2011 5 comments

原创文章,转载请注明: 转载自系统技术非业余研究

本文链接地址: slabtop简单的用途

我们知道内核的模块在分配资源的时候,为了提高效率和资源的利用率,都是透过slab来分配的。我们通过slab的信息,再配合源码能粗粗了解系统的运行情况,比如说什么资源有没有不正常的多,或者什么资源有没有泄漏。

linux系统透过/proc/slabinfo来向用户暴露slab的使用情况的,我们来看下:

$ head /proc/slabinfo 
slabinfo - version: 2.0
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <batchcount> <limit> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
msi_cache              2      2   3840    1    1 : tunables   24   12    8 : slabdata      2      2      0
ip_fib_alias          11    226     16  226    1 : tunables  120   60    8 : slabdata      1      1      0
ip_fib_hash           11    119     32  119    1 : tunables  120   60    8 : slabdata      1      1      0
dm_mirror            100    105   1052    7    2 : tunables   24   12    8 : slabdata     15     15      0
dm_mpath               0      0   1052    7    2 : tunables   24   12    8 : slabdata      0      0      0
dm_tio                 0      0     16  226    1 : tunables  120   60    8 : slabdata      0      0      0
dm_io                  0      0     20  185    1 : tunables  120   60    8 : slabdata      0      0      0
dm-bvec-(256)          0      0   3072    2    2 : tunables   24   12    8 : slabdata      0      0      0
...

其实还有更好的查看工具:slabtop很直观的可以看到slab使用情况和汇总,上图:

很清晰的为性能调优和trouble shoot提供一个参考面!

祝玩得开心!

Post Footer automatically generated by wp-posturl plugin for wordpress.

Categories: Linux, 工具介绍, 调优 Tags: