资料收集站

SDL

Monday
Jan 05th
Text size
  • Increase font size
  • Default font size
  • Decrease font size

编程资料

redhat linux 9.0 VSFTP配置大全

3.2 VSFTP—安全与效能兼备的ftp 服务器

3.2.1 VSFTP 概述

FTP,file transfer protocol,这是档案传输的通讯协议,也是一般最常用来传送档案的方式。读者在使用RedHat9 的时候,可能会感受到ftp server 有一些改变:第一,就是ftp server 只剩下vsftp,原有的wuftp 等都没放入﹔第二,就是vsftp 从XINETD 中独立出来,并将设定档从/etc/vsftpd.conf 之中移到/etc/vsftpd/vsftpd.conf。
 

mount

 名称 : mount
使用权限 : 系统管理者或/etc/fstab中允许的使用者

TAR命令参数详解

TAR
命令名
tar - tar 档案文件管理程序的 GNU 版本。下面将逐个介绍其含义

在Linux使用电视(视频)卡

许多人都拥有电视卡, 尽管您的电视卡的生产商可能并没有提供Linux的驱动.
但是 Linux 提供了对于电视卡中常见的bt8x8系列芯片的支持. 如果您手中的
卡符合条件的话, 那么开始行动吧.
Linux对于电视卡的支持, 是靠 Video4Linux 实现的, 通常可以简称为V4L.
现在较高版本的 Linux 内核已经包含V4L了, 并且默认的启动内核已经将
V4L以build-in或者模块方式编译好了. 所以一般来说, 发行商制作的Linux
您安装完毕以后已经可以直接使用V4L了. 而如果您自行编译如升级内核的
时候则要注意以下配置, 首先选中编译Mulitmedia devies-->Video for Linux,
再在Mulitmedia devies-->Video for Linux-->的各项按照您的电视卡的类型进
行配置, 如果您不确定的话不妨都选中(能按照模块编译的就按照模块编译)
对于支持FM收音功能的电视卡,同样按照配置上面的那样配置Mulitmedia devies-->
Radio Adapters各项,您可能还需要选中的Character devies-->I2C support-->
中的I2C Support,I2C device interface, I2C bit-banging interface及它下面
的几个子项.有的电视卡, 您还需选中Sound-->TV Card(bt848) mixer support.
以实现更好的支持. 是不是觉得异常复杂, 还好默认的安装方式已经替我们做好了
这些可怕的事情, 我们要做的就是直接配置电视卡的参数.
如果你的E文够好的话, 最好直接去看当前使用的内核文档中的
video4linux/bttv下的说明. 由于各个电视卡的差异, 我不敢妄自狂言, 只好
按照我所使用的电视卡(zoltrix TV-MAX use bt848chip & Philips Pal D/K Tuner)
加以说明了. 您需要的是配置/etc/modules.conf文件:
开始时 例如开始时可能为 modueles.conf 为
1 alias parport_lowlevel parport_pc
2 alias eth0 tulip
3 alias sound-slot-0 ymfpci
4 post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || :
5 pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || :
6 alias char-major-81 bttv
7 alias usb-controller usb-uhci
在第6行的后面加上
a pre-install bttv modprobe -k tuner
b options bttv radio=1 card=15
c options tuner type=23
其中b行中的radio=1表示电视卡支持声音, card=15为电视卡的厂商编号,
15代表Zoltrix TV-MAX, c行为电视卡使用的调谐器编号, 23代表Philips PAL D/K
您可以对照当前使用的内核的文档中 video4linux/bttv/CARDLIST文件的列表的
说明配置您的电视卡.

配置完成后重新启动, 开始收视软件的安装.
Linux收视软件有很多, 我比较喜欢 xawtv. 关于它的安装如同其他的软件一样,
下载的一般是源码, 那么在root用户下, 现将xawtv-???.gz.tar解压, 随后进入
解压后的子目录, 下面就是 ./configure; make ; make install之类的步骤,
如果无误的话, 执行xawtv(最好以root身份执行), 注意选择Frequency table
为china-bcast, 键盘的上下是选台, 左右是微调. 如果您能看到画面并且听到
伴音的话恭喜你, 否则的话, 在调整modules.conf的参数吧. 要还有疑问, 不妨
看看Linux的Howto文件中的关于电视卡的说明, 我就是从那里获益非浅.
祝你成功.

附录: Linux Kernel 2.4.7-10下的 CARDLIST

bttv.o
card=0 - *** UNKNOWN ***
card=1 - MIRO PCTV
card=2 - Hauppauge old
card=3 - STB
card=4 - Intel
card=5 - Diamond DTV2000
card=6 - AVerMedia TVPhone
card=7 - MATRIX-Vision MV-Delta
card=8 - Fly Video II
card=9 - TurboTV
card=10 - Hauppauge new (bt878)
card=11 - MIRO PCTV pro
card=12 - ADS Technologies Channel Surfer TV
card=13 - AVerMedia TVCapture 98
card=14 - Aimslab VHX
card=15 - Zoltrix TV-Max
card=16 - Pixelview PlayTV (bt878)
card=17 - Leadtek WinView 601
card=18 - AVEC Intercapture
card=19 - LifeView FlyKit w/o Tuner
card=20 - CEI Raffles Card
card=21 - Lucky Star Image World ConferenceTV
card=22 - Phoebe Tv Master + FM
card=23 - Modular Technology MM205 PCTV, bt878
card=24 - Askey/Typhoon/Anubis Magic TView CPH051/061 (bt878)
card=25 - Terratec/Vobis TV-Boostar
card=26 - Newer Hauppauge WinCam (bt878)
card=27 - MAXI TV Video PCI2
card=28 - Terratec TerraTV+
card=29 - Imagenation PXC200
card=30 - FlyVideo 98
card=31 - iProTV
card=32 - Intel Create and Share PCI
card=33 - Terratec TerraTValue
card=34 - Leadtek WinFast 2000
card=35 - Chronos Video Shuttle II
card=36 - Typhoon TView TV/FM Tuner
card=37 - PixelView PlayTV pro
card=38 - TView99 CPH063
card=39 - Pinnacle PCTV Studio/Rave
card=40 - STB2
card=41 - AVerMedia TVPhone 98
card=42 - ProVideo PV951
card=43 - Little OnAir TV
card=44 - Sigma TVII-FM
card=45 - MATRIX-Vision MV-Delta 2
card=46 - Zoltrix Genie TV/FM
card=47 - Terratec TV/Radio+
card=48 - Dynalink Magic TView
card=49 - GV-BCTV3
card=50 - Prolink PV-BT878P+4E (PixelView PlayTV PAK)
card=51 - Eagle Wireless Capricorn2 (bt878A)
card=52 - Pinnacle PCTV Studio Pro
card=53 - Typhoon TView RDS / FM Stereo
card=54 - Lifetec LT 9415 TV
card=55 - BESTBUY Easy TV
card=56 - FlyVideo 98/FM
card=57 - GrandTec Grand Video Capture
card=58 - Phoebe TV Master Only (No FM)
card=59 - TV Capturer
card=60 - MM100PCTV
card=61 - AG Electronics GMV1
card=62 - BESTBUY Easy TV (bt878)
card=63 - ATI TV-Wonder
card=64 - ATI TV-Wonder VE
card=65 - FlyVideo 2000S
card=66 - Terratec TValueRadio

tuner.o
type=0 - Temic PAL (4002 FH5)
type=1 - Philips PAL_I
type=2 - Philips NTSC
type=3 - Philips SECAM
type=4 - NoTuner
type=5 - Philips PAL
type=6 - Temic NTSC (4032 FY5)
type=7 - Temic PAL_I (4062 FY5)
type=8 - Temic NTSC (4036 FY5)
type=9 - Alps HSBH1
type=10 - Alps TSBE1
type=11 - Alps TSBB5
type=12 - Alps TSBE5
type=13 - Alps TSBC5
type=14 - Temic PAL_I (4006FH5)
type=15 - Alps TSCH6
type=16 - Temic PAL_DK (4016 FY5)
type=17 - Philips NTSC_M (MK2)
type=18 - Temic PAL_I (4066 FY5)
type=19 - Temic PAL* auto (4006 FN5)
type=20 - Temic PAL (4009 FR5)
type=21 - Temic NTSC (4039 FR5)
type=22 - Temic PAL/SECAM multi (4046 FM5)
type=23 - Philips PAL_DK
type=24 - Philips PAL/SECAM multi (FQ1216ME)
type=25 - LG PAL_I+FM (TAPC-I001D)
type=26 - LG PAL_I (TAPC-I701D)
type=27 - LG NTSC+FM (TPI8NSR01F)
type=28 - LG PAL_BG+FM (TPI8PSB01D)
type=29 - LG PAL_BG (TPI8PSB11D)
type=30 - Temic PAL* auto + FM (4009 FN5)

性能调试---(五)I/O性能分析

1:衡量I/O闲忙程度的指标
2:I/O资源成为系统性能的瓶颈的征兆
3:哪些活动是占用I/O资源的大户?
4:利用iostat分析I/O的利用率
5:利用SAR命令分析磁盘活动
6:利用SAR命令分析缓冲区的活动
7:利用SAR命令分析交换区的活动
8:利用GlancePlus分析系统的I/O活动情况
9:对I/O需求密集型系统的性能调试


衡量I/O闲忙程度的指标


下面是一些衡量I/O闲忙程度的经用指标:

磁盘利用率(disk utilization)
磁盘队列长度(disk queue length)
磁头/逻辑卷的读/写速率(read/write rates per spindle/logical volume)
原始I/O(raw I/O):主要用于数据库应用
交换队列的长度(swap queue length)
缓存命中率(buffer cache hit ratio)
网络文件系统和无盘工作站速率(NFS and diskless rates(server))
{mospagebreak}
I/O资源成为系统性能的瓶颈的征兆


当I/O成为瓶颈时,会出现下面这些典型的症状:

过高的磁盘利用率(high disk utilization)
太长的磁盘等待队列(large disk queue length)
等待磁盘I/O的时间所占的百分率太高(large percentage of time waiting for disk I/O)
太高的物理I/O速率:large physical I/O rate(not sufficient in itself)
过低的缓存命中率(low buffer cache hit ratio(not sufficient in itself))
太长的运行进程队列,但CPU却空闲(large run queue with idle CPU)

哪些活动是占用I/O资源的大户?


下面是一些占用大量I/O资源的活动:

换页(paging):paging不仅会引起内存问题,还可能引起磁盘问题;
open,creat,and stat system calls:系统调用会引起大量的磁盘I/O;
multiuser I/O and random I/O
relational database
core dumps

{mospagebreak}
利用iostat分析I/O的利用率


iostat - report I/O statistics

iostat iteratively reports I/O statistics for each active disk on the system.

If two or more disks are present, data is presented on successive lines for each disk.

With the advent of new disk technologies, such as data striping, where a single data transfer is spread across several disks, the number of milliseconds per average seek becomes impossible to compute accurately. At best it is only an approximation, varying greatly, based on several dynamic system conditions. For this reason and to maintain backward compatibility, the milliseconds per average seek ( msps ) field is set to the value 1.0.

它的语法为:

iostat [-t] [interval [count]]

其选项的含义为:

-t:Report terminal statistics as well as disk statistics.
interval: Display successive lines which are summaries of the last interval seconds. The first line reported is for the time since a reboot and each subsequent line is for the last interval only.
count: Repeat the statistics count times.
对结果的分析:

通过查看bps列和sps列的值我们可以知道哪些磁盘比较忙,哪些磁盘比较闲。

{mospagebreak}
利用SAR命令分析磁盘活动


通过命令sar -d,我们可以分析系统中的每个磁盘和磁带的活动情况。

Report activity for each block device, e.g., disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed.Each line contains the following data:

device:设备名;
%busy: Portion of time device was busy servicing a request; statistics.
avque: Average number of requests outstanding for the device;
r+w/s: Number of data transfers per second (read and writes) from and to the device;
blks/s: Number of bytes transferred (in 512-byte units) from and to the device;
avwait: Average time (in milliseconds) that transfer requests waited idly on queue for the device;
avserv: Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for the device.
对结果的分析:

如果某个磁盘的%busy列的值大于50%,则说明该磁盘可能存在瓶颈;

如果某个磁盘的avwait珍的值大于avserv列的值,也说明该磁盘可能存在瓶颈;

{mospagebreak}
利用SAR命令分析缓冲区的活动


通过命令sar -b,我们可以分析系统中的缓冲区的活动情况。

Report activity for each block device, e.g., disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed.Each line contains the following data:

bread/s Number of physical reads per second from the disk (or other block devices) to the buffer cache;
bwrit/s: Number of physical writes per second from the buffer cache to the disk (or other block device);
lread/s: Number of reads per second from buffer cache;
lwrit/s: Number of writes per second to buffer cache;
%rcache: Buffer cache hit ratio for read requests e.g., 1 - bread/lread;
%wcache: Buffer cache hit ratio for write requests e.g., 1 - bwrit/lwrit;
pread/s: Number of reads per second from character device using the physio() (raw I/O) mechanism;
pwrit/s: Number of writes per second to character device using the physio() (i.e., raw I/O ) mechanism; mechanism.
对结果的分析:

如果%rcache列的值小于90%,并且%wcache列的值不在70-70%之间,我们必须观察系统中什么应用在做什么样的读/写操作,我们是否需要增加缓冲欧的大小。

{mospagebreak}
利用SAR命令分析交换区的活动


通过命令sar -w,我们可以分析系统中的交换区的活动情况。

Report activity for each block device, e.g., disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed.Each line contains the following data:

swpin/s: Number of process swapins per second;
swpot/s: Number of process swapouts per second;
bswin/s: Number of 512-byte units transferred for swapins per second;
bswot/s: Number of 512-byte units transferred for swapouts per second;
pswch/s: Number of process context switches per second.
对结果的分析:

如果swpin/s的值大于零,那么swpot的值必须引起注意;

同时必须注意pswch/s的值,如果很大,说明进程切换频繁。


{mospagebreak}
利用GlancePlus分析系统的I/O活动情况


1)对磁盘的整体使用情况的分析:

进入GlancePlus;
按?键进入联机帮助界面;
按d键进入磁盘的详细界面;
按b键表示向后翻页,按f键表示向前翻页;
通过Disk Detail Screen,我们可以知道所有的逻辑和物理I/O请求的分布情况。

2)对Disk I/O by File System

进入GlancePlus;
按?键进入联机帮助界面;
按i键Disk I/O by File System表界面;
按b键表示向后翻页,按f键表示向前翻页;
这个界面很有用,因为它按不同的文件显示I/O的繁忙程度。

3)对逻辑卷的分析

进入GlancePlus;
按?键进入联机帮助界面;
按v键I/O by logical volumes表界面;
按b键表示向后翻页,按f键表示向前翻页;
通过把对文件系统的分析和逻辑卷的分析结合起来,能够知道哪个磁盘的I/O最忙。

4)对磁盘的分析

5)对交换区的分析

{mospagebreak}
GlancePlus


GlancePlus是HP公司的性能分析工具,它是一个联机性能分析和诊断工具,用于监控正在发生的系统活动情况。它的特点是:

联机性能分析和诊断;
监控系统资源的使用情况;
多屏幕输出;
带有联机帮助;
进程阀值识别和报警,这个阀值可以基于被监控的进程、资源的利用率、用户、进程名或者终端名;
和前面介绍的其他性能分析工具,如:SAR,iostat,vmstat等相比,GlancePlus有一最大好处,这就是:GlancePlus不仅能对系统的整体情况进行分析,而且还可以对某个进程进行深入分析。

GlancePlus所有监控的系统资源主要有以下这些,应该说,它们已经包括了主要的系统资源。

CPU、磁盘、内存和交换区的整体使用情况;
全局进程的活动情况;
CPU的详细使用情况;
内存的详细使用情况;
文件系统、设备和逻辑卷的磁盘输入/输出;
磁盘队列和长度;
交换区的详细使用情况;
系统表的使用情况;
单个进程的活动情况;
GlancePlus的运行形式有两种:

图 形方式:#/opt/perf/bin/gpm,或以后台方式运行#gpm&;不过,我们必须先设置环境变量DISPLAY,因为它是图形输出的 目的地,比如:export DISPLAY=主机名(IP地址):0.0;如果是工作站telnet别的主机上,则本工作站还要运行#xhost +,表示别的机器上输出可以到本工作站;
终端方式:#/opt/perf/bin/glance
GlancePlus的界面主要有两部分,上面部分是系统资源的整体使用情况,下面部分则按不同的资源的详细使用情况。

GlancePlus的界面的上面部分的详细说明,其中字母表示谁用了资源,而字母之间的长度资源占用率。

CPU的利用率:S-系统CPU利用率,U-用户CPU利用率,R-实时CPU利用率,N-nice CPU利用率,A-negative-nice CPU利用率;
磁盘的利用率:F-文件系统I/O,V-虚拟内存I/O
内存的利用率:S-用于系统代码和数据的内存,U-用于用户代码和数据的内存,B-用作缓存的内存
交换区的利用率:U-正在使用的交换区,R-预留的交换区
前 面讲到,GlancePlus是一个联机分析诊断工具,其实,GlancePlus还可以与MeasureWare Agent一起使用,MeasureWare Agent将可以 在一段时间内帮助GlancePlus收集基本数据,然后由GlancePlus进行分析。

Glance可以运行在HP-UX,Solaris和AIX上。

与其他的工具相比,Glance占用的系统资源会更多一些。

通常情况下,启动工具的命令的语法如下:

#glance [-j interval][-p dest][-f dest][maxpagers n][-command][-nice n][-nosort][lock][]

其中,各选项的含义为:

-j :指定数据刷新的时间间隔;
-p :使得结果送到打印机队列;
-f :enbles printing to a file;
-maxpages :limits the number of pages to be printed;
-command:selects the inital metric screen;
-nice :nice value at which glance runs;
-nosort:don't sort processes on the screen;
-lock:locks glance into memory

http://thor.prohosting.com/~nlingym/os/hpux/tuning/io/cputuning.html

Last Updated ( Friday, 14 October 2005 23:55 )

性能调试---(四)内存性能分析

1:内存管理
2:衡量内存闲忙程度的指标
3:内存资源成为系统性能的瓶颈的征兆
4:什么地方/哪些进程是占用内存资源的大户?
5:利用vmstat命令分析内存的利用率
6:利用ipcs分析消息队列、共享内存和信号量
7:利用GlancePlus分析系统内存资源利用率
8:对内存需求密集型系统的性能调试


内存管理


1)内存管理的主要工作:

跟踪内存的使用和可用内存的情况;
为进程分配内存;
管理磁盘与物理内存之间的换页(paging);
2)什么是虚拟内存(virtual memory)?

virtual memory uses a disk as an extension of RAM so that the effective size of usable memory grows correspondingly. The kernel will write the contents of a currently unused block of memory to the hard disk so that the memory can be used for another purpose. When the original contents are needed again, they are read back into memory. This is all made completely transparent to the user; programs only see the larger amount of memory available and don't notice that parts of them reside on the disk from time to time. Of course, reading and writing the hard disk is slower (on the order of a thousand times slower) than using real memory, so the programs don't run as fast. The part of the hard disk that is used as virtual memory is called the swap space.

物理内存(physical memory)
swap space:
3)paging

A technique by which the contents of a virtual memory address(called pages) are moved from virtual memory(the disk)into and out of the main memory where it is accessed by the CPU.

这个机制是由一个叫vhand的进程来完成。

当 可用内存的数量小于LOTSFREE时,例程pageout将被调用来选择什么内存可以释放。它采用two-handed clock algorithm,the reference hand turn off the reference bit of each memory page it references.If the refernce bit is still zero when the second hand gets to it,the page is freed.If the page is clean(unmodified),it is added to the freelist.If the page is dirty,it must be posted to the swap device before being put on the freelist.

lotsfree: based on physical memory (64 MB -> 863) upper bound where paging starts/stops
desfree: based on physical memory (64 MB -> 215)lower bound where paging starts/stops
minfree: based on physical memory (64 MB -> 53) threshold where deactivation starts
4)Page fault

An invalid address error(trap)that occurs when the CPU requests a page from memory that has not been paged in from the disk(virtual memory)to the main memory. The page may also have been paged out from the main memory prior the request.

5)Process Deactivaton

Deactivating a process so its memory pages will be flagged free or paged out rapidly by vhand.

6)Thrashing

A situation in which a process is spending more time paging than processing;a high number of page faults is occuring.

7)Buffer Cache

它是内存的一部分,用于加快文件存取时间;
缓存的大小可以随可用内存动态变化,但也可以通过修改内核参数而改成固定的大小;
缓存可以提高磁盘的读/写性能;
在缓存的内容可以通过sync进程来强制写入磁盘;
从缓存的读和写又称为逻辑读和逻辑写;
8)内存需求

按用途来分,内存可以分成两部分:预留内存和动态内存。

预留内存主要用于存放:

system table
data structures
buffer cache
其中系统表和数据结构占用的数量一般很小,但缓存则可能占到很大一部分。

动态内存主要用于存放:

process text
data stack
share memory segments
其中各进程锁定的内存会影响动态内存的大小。


衡量内存闲忙程度的指标


1)整体内存忙闲指标:

buffer cache size: 缓存区在内存开销中占很大比例;
page in/out rates;
swap in/out rates;
可用内存的大小,或用得到内存的大小(available memory size):
自 由内存的大小(free memory size): what is currently available,it should not be confuzed with available memory,which does not change during normal sytem operation;
swap queue length;
2)单个进程的内存衡量指标:

一个进程占用物理内存的大小(resident set size)
一个进程占用虚拟内存的大小(virtual set size)
VM reads and writes: it can show how many physical memory management reads and writes were made to and from the disk during the chosen interval.

内存资源成为系统性能的瓶颈的征兆


当内存资源成为系统性能的瓶颈时,它有一些典型的症状:

很 高的换页率(high pageout rate):HP-UX是一个按需调页的操作系统,通常情况下,它只执行调入页面进入内存的操作,以让进程能够运行。只有操作系统觉得系统需要释放一些内 存空间时,才会执行从内存调出页面的操作,而过高的调出页面操作说明内存缺乏;
进程进入不活动状态(process deactivation activity):当自由的内存页面数量小于MINFREE时,很多进程将强制进入不活动状态,因为,any deactivation activity represents a condition in which normal paging is inadequate to handle the memory demands.
自由内存的数量很小,但活动的虚拟内存却很大(very small free memory and large active virtual memory)
交换区所有磁盘的活动次数可高(high disk activity on swap devices)
可高的全局系统CPU利用率(high global system CPU utilization):
很长的运行进程队列,但CPU的空闲时间却很多(large run queue with idle CPU)
内存不够出错(out of memory errors)
CPU用于vhand和swapper两中守护进程的时间(CPU time to vhand and swapper)
必须注意的是,有时候我们发现CPU很忙,这似乎是CPU资源成为系统性能的瓶颈,但如果进一步分析,发现vhand和swapper守护进程占用了大量的系统CPU时间,很显然,这时系统性能瓶颈真正所在可能是内存。


什么地方/哪些进程是占用内存资源的大户?


下面是一些典型的占用内存资源的大户:

buffer cache
plocked process:plocked processes are those that are locked in memory and are not elogible to be paged.通常,这些进程都是一些比较重要的进程,不便调出内存。
档案库(archive libraries):把库放入内存可以加快程序的执行,但它们将占用大量的内存;
共享内存(shared memory)
关系型数据库(relational databases)
X-终端和X-服务器进程(X-terminals and X-servers):通常,一个X-终端需要额外的2-4兆内存;一个X-服务器需要400KB以上的内存;

利用vmstat命令分析内存的利用率


vmstat-report virtual memory statistics

The vmstat command reports certain statistics kept about process, virtual memory, trap, and CPU activity. It also can clear the accumulators in the kernel sum structure.

它的语法:

vmstat [-dnS] [interval [count]]

vmstat -f | -s | -z

它的选项的说明:

-d: Report disk transfer information as a separate section, in the form of transfers per second.
-n: Provide an output format that is more easily viewed on an 80-column display device. This format separates the default output into two groups: virtual memory information and CPU data. Each group is displayed as a separate line of output. On multiprocessor systems, this display format also provides CPU utilization on a per CPU basis.
-S: Report the number of processes swapped in and out (si and so) instead of page reclaims and address translation faults (re and at)
interval: Display successive lines which are summaries over the last interval seconds. If interval is zero, the output is displayed once only. If the -d option is specified, the column headers are repeated. If -d is omitted, the column headers are not repeated.
count: Repeat the summary statistics count times. If count is omitted or zero, the output is repeated until an interrupt or quit signal is received.
-f: Report on the number of forks and the number of pages of virtual memory involved since boot-up.
-s: Print the total number of several kinds of paging- related events from the kernel sum structure that have occurred since boot-up or since vmstat was last executed with the -z option.
-z: Clear all accumulators in the kernel sum structure. This option is restricted to the super user.
对结果的说明:

在 不带参数的vmstat的命令时,我们首先要关注的是avm(active virtual memory)列和free(free list zise)列的值。如果avm的值很大,而free的值却很小,这时,系统可能有内存瓶颈,我们 必须用带-S选项的vmstat命令查看系统是否有deactivation/reactivation活动正在发生。


利用ipcs分析消息队列、共享内存和信号量


ipcs - report status of interprocess communication facilities

ipcs displays certain information about active interprocess communication facilities. With no options, ipcs displays information in short format for the message queues, shared memory segments, and semaphores that are currently active in the system.

它的语法:

ipcs [-mqs] [-abcopt] [-C core] [-N namelist]


利用GlancePlus分析系统内存资源利用率


利用HP的GlancePlus可以对内存使用情况进行分析:

进入GlancePlus;
按?键进入联机帮助界面;
按m键进入内存的详细界面;
通过memory Detail Screen,我们可以知道内存的分布情况,物理内存多少、缓存多少、用户用了多少,系统用了多少、以及换页情况等。


对内存需求密集型系统的性能调试


1)基于硬件的方法:

增加物理内存
使用无盘工作站替代X-terminal
2)基于软件的方法:

减小内核参数maxdsiz的值;
减少内存锁定的使用;
杀死不必要的进程;
识别出需要大量内存的进程;
重新设计应用;
减小内核的大小;
减小系统表的大小;
减小缓存区的大小;
3)利用serialize命令来调度大进程的系统资源需求

/usr/bin/serialize applicaiton
/usr/bin/serialize -p pid

性能调试---(三)CPU性能分析

1:CPU的体系结构和工作原理
2:操作系统和进程
3:衡量CPU闲忙程度的指标
4:CPU资源成为系统性能的瓶颈的征兆
5:哪些进程是占用CPU资源的大户?
6:利用SAR工具分析CPU的利用率
7:利用SAR工具分析运行进程队列长度
8:利用SAR工具分析系统调用
9:利用time命令测试某个命令和程序的执行效率
10:利用top命令查看最耗CPU资源的进程
11:利用uptime命令查看系统整体情况
12:利用GlancePlus分析系统CPU资源利用率
13:对CPU需求密集型系统的性能调试


CPU的体系结构和工作原理


我们所说的CPU一般是指微处理器,即Microprocessor,一般地,一个CPU的主要组成部分为:

CPU(central processing unit)
cache:cache就是高速内存,它的存取时间一般是10-20微秒(ns),这样,CPU可以在一个时钟周期内访问一次cache;而一般的内存的存取时间为80-90微秒(ns),它的大小对CPU的性能有很大的影响。
TLB(translation lookaside boffer):TLB是高速cache,它用于存放最近访问的虚拟地址和与其对应的物理地址对,这样TLB将可以把虚拟地址转换为物理地址。TLB是内 存中系统转换表的一个子集;TLB通常是指向一个内存页面,而不是一个内存地址;它的大小对CPU的性能有很大的影响。
coprocessor
不同的CPU,一般有不同的时钟频率和高速缓存容量。

CPU在一次时钟周期内一般可以从高速缓存内取到一个指令并执行它。因此,从理论上说,只要CPU的主频越快,单位时间内所能执行的指令则越多。目前,有些CPU可以在一个时钟周期内执行多条指令,如PA8500可以执行4条指令。
高速缓存的大小会制约CPU的执行效率,虽然CPU主频很快,但它取不到数据,则只有空运行。因此,高速缓存的大小很重要;高速缓存又分数据高速缓存和指令高速缓存,分别存放从内存预先取来的即将执行的数据和指令单元。
虚拟寻址

一般,系统中的虚拟地址空间要比物理地址空间大得多,例如,如果系统是64位的,则理论上,它的寻址空间可以达到2的64次幂(2**64=18,447PB),但由于受费用的因素的影响,实际上的物理内存最大只有十几GB的内存。

每个进程都有自己的唯一虚拟地址空间,然而,进程的运行必须把虚拟地址映射到物理地址,这需要TLB、高速缓存和内存三者的配合。如果需要的信息不在内存,则导致一个页面错。

流水线(Pipelining)

TLB 和高速缓存试图在一个时钟周期内给CPU提供它所需的信息,然而,这个过程是100%的利用率,对CPU来说,它必须先用一个时钟周期去取下一个指令,再 一个时钟周期去执行这条指令,这样,CPU的利用率也只有50%。为了让CPU更忙,通常的做法是,采用流水线的方法。如PA8500是采用7个步骤的流 水线。

操作系统和进程


HP-UX一个多用户、多任务的UNIX操作系统。它的性能依赖于用户数的多少、用户任务的类型、硬/软件件的配置。

HP-UX有两种运行级别:

用户级:系统用户可以与操作系统进行交互操作,如运行应用和系统命令。用户级通过系统调用接口访问内核级。
内核级:操作系统自动运行一些功能,它们主要对硬件进行操作。
在操作系统中,用户程序是以进程方式运行。进程的状态有以下几种:

SRUN
SSLEEP
SZOMB
SIDL
SSTOP
CPU的调度

一旦进程所需的数据调入内存后,它将等待CPU调度者来分配CPU时间。一般,在HP-UX中,每个进程都可以得一个 固定的时间片来运行,这个时间片的长度为十分之一秒(1/10秒)。

由 于HP-UX是一个多任务的操作系统,它需要一种手段来进程的执行次序,这就是中断。在系统中,时钟中断处理器是用来处理时钟中断的系统软件。具体地说, 它将收集系统和accounting statistics and does context switching.系统性能也与这种中断发生的频率有关。

进程何优先级

每个进程都有自己的优先级;
实时优先级:-32~127,一个进程如果想以实时优先级运行,则必须用命令#rtprio来设置;
分时系统优先级:128~177;
分时用户优先级:178~251;
优先级:252~255 are used by the system as virtual memory management priorities for process deactivation.
分时进程在初始优先级是由系统分配的,为一个定值。用户可以通过改变进程的nice值来改变分时进程的优先级。因为进程会随着它的执行,将以nice值来降低它的优先级,当 它在等待执行时,又将以nice值来增加其优先级。nice值的系统缺值为20。
在系统性能分析过程中,我关心不仅仅在完成一个进程耗时多少,还包括时间花在哪以及它的时间多少。


衡量CPU闲忙程度的指标


要分析系统的CPU资源是否够的前提谁占用了CPU资源,占用了多少,时间多长。 下面是一些衡量CPU闲忙程度的经用指标:

1)用户使用CPU的情况

CPU运行常规用户进程
CPU运行niced process
CPU运行实时进程
2)系统使用CPU的情况

用于系统调用
用于I/O管理:中断和驱动
用于内存管理:paging and swapping
用于进程管理:context switch and process start
3)WIO:由于进程等待I/O而使CPU处于空闲状态的比率,这些I/O主要指block I/O,raw I/O,VM paging/swapins;

4)CPU的空闲率,即除了上面的WIO以外的空闲情况;

5)CPU用于上下文交换的比率(Context Switch CPU utilization)

6)nice

7)real-time

8)运行进程队列的长度,即处于可运行状态的进程个数的大小,不过我们关心的是这些在等待CPU调度执行时所花的时间;

9)平均负载(load average)


CPU资源成为系统性能的瓶颈的征兆


CPU就像人的大脑,完成各种交给它的任务。如果任务太多,CPU就要忙不过来,它的运行效率就要下降。就像人生病会有一典型症状一样,当CPU资源 成为系统性能的瓶颈时,它也有一些典型的症状:

很慢的响应时间(slow response time)
CPU空闲时间为零(zero percent idle CPU)
过高的用户占用CPU时间(high percent user CPU)
过高的系统占用CPU时间(high percent system CPU)
长时间的有很长的运行进程队列(large run queue size sustained over time)
processes blocked on prority
必 须注意的是,如果系统出现上面的这些症状并不能说一定是由于CPU资源不够,事实,有些症状 的出现很可能是由于其他资源的不足而引起,如内存不够时,CPU会忙内存管理的事,这时从表面上, CPU的利用是100%,甚至显得不够,如果据此就简单地认为增加CPU就可以解决问题是大错特错了。

因此,还是那句话,必须用不同的工具、从不同的方面对系统进行分析后,才能做出结论,即使这样,经验将 起到不可替代的作用。


哪些进程是占用CPU资源的大户?


在操作系统中,并不是所有的进程都以同样的方式使用CPU资源。通常情况下,有些进程需要比其他进程更多的CPU时间片才能顺利地完成任务。 下面是一些典型的占用CPU资源的大户:

进程创建(process creation)
终端字符进程(teminal character processes(MUX- and LAN-based)
计算密集型进程和实时进程
X-终端和X-服务器进程(X-terminals and X-servers)


利用SAR工具分析CPU的利用率


利用SAR进行CPU的利用率分析的命令形式:

#sar -u,这时数据是通过sa1在后台定时生成;
#sar -u 5 100,每隔5秒取样一次,共取100次;
SAR -u:Report CPU utilization (the default); portion of time running in one of several modes. On a multi-processor system, if the -M option is used together with the -u option, per-CPU utilization as well as the average CPU utilization of all the processors are reported. If the -M option is not used, only the average CPU utilization of all the processors is reported:

cpu: cpu number (only on a multi-processor system with the -M option);
%usr: user mode;
%sys: system mode;
%wio: idle with some process waiting for I/O (only block I/O, raw I/O, or VM pageins/swapins indicated);
%idle: otherwise idle;
对结果的分析

首先,我们看%idle列的值,如果为接近零,则再看对应%wio列的值,如果这列的大于7,则表明系统的磁盘或其他I/O可能有问题,需要进一步的分析:

用iostat命令分析各个磁盘的传输闲忙状况,如#iostat -t 5 2,每隔5秒取样一次,共取2次;
用sar -d命令分析各块设备(磁盘、磁带)活动情况;
用sar -b命令分析系统的缓存的活动情况;
用sar -w命令分析进程的deactivation/reactivation and switching activities of the system;
如果%idle列很小,而对应的%wio列的值也很小,这时,我们查看%usr列和%sys列的值。如果%usr列的值很大,说明有用户进程占用很多CPU时间;如果%sys列的值很大,则说明系统管理方面花了很多时间。需要进一步的分析:

用GlancePlus对占用CPU时间最大的进程进行单独分析,为什么它会占用如此多的CPU时间。
如 果%sys列的值很大,可以用SAR -C命令对系统调用进行进一步分解,看这些系统调用主要是做些什么。同时,还必须分析是否有其他瓶颈,如paging也会引起%sys的值很大,这时,可 以用sar -q查看系统的运行进程队列长度,也可以用GlancePlus和vmstat查看内存的使用情况;

利用SAR工具分析运行进程队列长度


利用SAR进行运行进程队列长度分析的命令形式:

#sar -q,这时数据是通过sa1在后台定时生成;
#sar -q 5 100,每隔5秒取样一次,共取100次;
SAR -q: Report average queue length while occupied, and percent of time occupied. On a multi-processor machine, if the -M option is used together with the -q option, the per-CPU run queue as well as the average run queue of all the processors are reported. If the -M option is not used, only the average run queue information of all the processors is reported:

cpu: cpu number (only on a multi-processor system with the -M option);
runq-sz: Average length of the run queue(s) of processes (in memory and runnable);
%runocc: The percentage of time the run queue(s) were occupied by processes (in memory and runnable);
swpq-sz: Average length of the swap queue of runnable processes (processes swapped out but ready to run);
%swpocc: The percentage of time the swap queue of runnable processes (processes swapped out but ready to run) was occupied.
对结果的分析:

这些数据越小越好。

如果runq-sz大于4,或者%swapocc大于5时,则表明系统的CPU或内存可能有问题,需要进一步的分析:

用sar -u命令分析CPU的使用情况;
用sar -w命令分析进程的deactivation/reactivation and switching activities of the system;
也可以用GlancePlus;

利用SAR工具分析系统调用


利用SAR进行系统调用分析的命令形式:

#sar -c,这时数据是通过sa1在后台定时生成;
#sar -c 5 100,每隔5秒取样一次,共取100次;
SAR -c: Report system calls:

scall/s: Number of system calls of all types per second;
sread/s: Number of read() and/or readv() system calls per second;
swrit/s: Number of write() and/or writev() system calls per second;
swpq-sz: Average length of the swap queue of runnable processes (processes swapped out but ready to run);
fork/s: Number of fork() and/or vfork() system calls per second;
exec/s: Number of exec() system calls per second;
rchar/s: Number of characters transferred by read system calls block devices only) per second;
wchar/s: Number of characters transferred by write system calls (block devices only) per second.
对结果的分析:

如果scall/s列的值很大,那么这么多的系统调用的原因就必须仔细分析了。

我们可以查看fork/s和exec/s列的值,看看系统是否在创建大量新的进程。



利用time命令测试某个命令和程序的执行效率


我们可以利用time命令来测试一个命令的执行效率,语法为:

time command

command is executed. Upon completion, time prints the elapsed time during the command, the time spent in the system, and the time spent executing the command. Times are reported in seconds.

Execution time can depend on the performance of the memory in which the program is running.

当我们觉得某个进程的性能不好时,最简单的方法就是利用time命令来查看一下进程执行时它的 时间分布情况,然后再用其他工具进一步分析。


利用top命令查看最耗CPU资源的进程


我们可以利用top命令来查看最耗CPU资源的进程。top命令还会根据进程占用CPU资源的多少而动态改变。

它的语法为:

top [-s time] [-d count] [-q] [-u] [-h] [-n number]

其中各选项的含义为:

-s time: 屏幕刷新的时间间隔time,缺省为5秒;
-d count: 屏幕刷新count次后,top命令自己也退出;
-q: This option runs the top program at the same priority as if it is executed via a nice -20 command so that it will execute faster (see nice(1)). This can be very useful in discovering any system problem when the system is very sluggish. This option is accessibly only to users who have appropriate privileges.
-u: User ID (uid) numbers are displayed instead of usernames. This improves execution speed by eliminating the additional time required to map uid numbers to user names.
-h: Hides the individual CPU state information for systems having multiple processors. Only the average CPU status will be displayed.
-n number: Show only number processes per screen. Note that this option is ignored if number is greater than the maximum number of processes that can be displayed per screen.
在top命令运行时,我们可用以下几个快捷键来翻屏:

j: 向前翻;
k: 向后翻;
t: 回到第一页;
对结果的分析:

通过top命令,我们可以快速了解到目前系统的CPU资源使用情况,尤其是占用CPU资源最多的进程是我们必须关注的对象。

我们通过RES(the current size of the process resident in memory)列可以知道每个进程占用内存的数量。

我们通过NICE列可以知道系统是否使用NICE值来调节该进程的工作负载平衡。

利用uptime命令查看系统整体情况


uptime prints the current time, the length of time the system has been up, the number of users logged on to the system, and the average number of jobs in the run queue over the last 1, 5, and 15 minutes.

w is linked to uptime and prints the same output as uptime -w, displaying a summary of the current activity on the system.

它的语法为:

uptime [-hlsuw] [user]

w [-hlsuw] [user]

其中各选项的含义为:

-h: Suppress the first line and the heading line. This option should not be used with the -u option. This option assumes the use of the -w option to uptime.
-l: Use long output. This option assumes the use of the -w option to uptime.
-s: Use the short form of output for displaying terminal information. The terminal name is abbreviated; the login time and CPU times are suppressed.
-u: Print only the first line describing the overall state of the system. This is the default for the uptime command.ormation for systems having multiple processors. Only the average CPU status will be displayed.
-w: Print a summary of the current activity on the system for each user. This is the default for the w command.

利用GlancePlus分析系统CPU资源利用率


利用HP的GlancePlus工具可以对进程的整体情况和单独的某个进程都详细分析。

1)对CPU的整体使用情况的分析:

进入GlancePlus;
按?键进入联机帮助界面;
按c键进入CPU的详细界面;
按b键表示向后翻页,按f键表示向前翻页;
通过CPU Detail Screen,我们可以知道CPU时间的分布情况,用户用了多少,系统用了多少等。

2)对单个进程的CPU资源占用情况分析:

进入GlancePlus;
按?键进入联机帮助界面;
按g键进入进程列表界面;
按s键进入进程选择界面,通常最忙的进程会作为缺省进程;
输入想查看的进程号;
按b键表示向后翻页,按f键表示向前翻页;
在对单个进程的分析中,我们通常要关注以下几个值:

CPU Usage;
User CPU;
System CPU;
Priority;
Logical and Physical Reads and Writes;
Total RSS/VSS;
blocked on(通过按shift+>来得到);

对CPU需求密集型系统的性能调试


1)基于硬件的方法:

升级到更快的CPU;
升级到更大的高速缓存;
增加CPU个数;
把应用分布到多个系统中;
使用无盘结点;
增加浮点处理器;
2)基于软件的方法:

在不是高峰时间运行批处理;
Nice umimportant application;
使用rtpio命令来帮助重要的应用;
使用plock命令来帮助重要的应用;
Turn off system accounting;
Consider using Taskbroker or DCE;
优化应用;
考虑使用进程资源管理器(Process Resource Manager),不过PRM只有在HP-UX平台上有。
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »
Page 1 of 2

Google 搜索

在线用户

We have 63 guests online