Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1786366
  • 博文数量: 1647
  • 博客积分: 80000
  • 博客等级: 元帅
  • 技术积分: 9980
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-13 15:15
文章分类

全部博文(1647)

文章存档

2011年(1)

2008年(1646)

我的朋友

分类:

2008-10-28 18:04:51


  说明:由于STATSPACK并不能获取全面分析性能问题所需要的所有信息,所以需要扩展其收集的统计信息。(本文环境REDHAT Linux7.2)
  
  VMSTAT介绍
  
  通过STATSPACK收集信息,主要通过收集VMSTAT的信息来展现服务器状况。VMSTAT工具是最常见的UNIX监控工具,可以展现给定时间间隔的服务器的状态值。
  
  一般VMSTAT工具的使用是通过两个数字参数来完成的,第一个参数是采样的时间间隔数,单位是秒,第二个参数是采样的次数。如:
  
  [oracle@brucelau oracle]$ vmstat 1 2
  
  procs           memory  swap     io system     CPU
  
  r b w  swpd  free  buff cache  si so  bi  bo  in  cs us sy id
  
  1 0 0   0 271844 186052 255852  0  0   2   6 102  10  0  0 100
  
  0 0 0   0 271844 186052 255852  0  0   0   0 104  11  0  0 100
  
  (注:目前系统几乎空闲,并且不同操作系统VMSTAT输出内容有所不同)
  
  目前说来,对于服务器监控有用处的度量主要有:
  
  r(运行队列)
  
  pi(页导入)
  
  us(用户CPU)
  
  sy(系统CPU)
  
  id(空闲)
  
  通过VMSTAT识别CPU瓶颈
  
  r(运行队列)展示了正在执行和等待CPU资源的任务个数。当这个值超过了CPU数目,就会出现CPU瓶颈了。
  
  获得CPU个数的命令(LINUX环境):
  
  cat /proc/cpuinfo|grep processor|wc –l
  
  当r值超过了CPU个数,就会出现CPU瓶颈,解决办法大体几种:
  
  1.    最简单的就是增加CPU个数
  
  2.    通过调整任务执行时间,如大任务放到系统不繁忙的情况下进行执行,进尔平衡系统任务
  
  3.    调整已有任务的优先级
  
  通过VMSTAT识别CPU满负荷
  
  首先需要声明一点的是,vmstat中CPU的度量是百分比的。当us+sy的值接近100的时候,表示CPU正在接近满负荷工作。但要注意的是,CPU满负荷工作并不能说明什么,UNIX总是试图要CPU尽可能的繁忙,使得任务的吞吐量最大化。唯一能够确定CPU瓶颈的还是r(运行队列)的值。
  
  通过VMSTAT识别RAM瓶颈
  
  数据库服务器都只有有限的RAM,出现内存争用现象是的常见问题。
  
  首先察看RAM的数量,命令如下(LINUX环境):
  
  [root@brucelau root]#free
  
  total    used    free   shared  buffers   cached
  
  Mem:    1027348   873312   154036   185736   187496   293964
  
  -/+ buffers/cache:   391852   635496
  
  Swap:   2096440     0  2096440
  
  当然可以使用top等其他命令来显示RAM。
  
  当内存的需求大于RAM的数量,服务器启动了虚拟内存机制,通过虚拟内存,可以将RAM段移到SWAP DISK的特殊磁盘段上,这样会出现虚拟内存的页导出和页导入现象,页导出并不能说明RAM瓶颈,虚拟内存系统经常会对内存段进行页导出,但页导入操作就表明了服务器需要更多的内存了,页导入需要从SWAP DISK上将内存段复制回RAM,导致服务器速度变慢。
  
  解决的办法有几种:
  
  1.    最简单的,加大RAM
  
  2.    改小SGA,使得对RAM需求减少
  
  3.    减少RAM的需求(如:减少PGA)
  
  我们基本的了解了VMSTAT工作,下面是STATSPACK通过vmstat统计收集服务器性能数据。
  
  STATSPACK通过vmstat收集服务器信息
  
  首先在perfstat用户下建一个服务器信息的表:如
  
  建表:
  
  create table stats$vmstat
  
  (
  
  start_date    date, --系统时间
  
  duration  date, --时间间隔
  
  server_name    varchar2(20), --服务器名称
  
  runque_waits    number, --运行队列数据
  
  page_in     number, --页导入数据
  
  page_out    number, --页导出数据
  
  user_cpu    number, --用户cpu数据
  
  system_cpu    number, --系统cpu数据
  
  idle_cpu    number, --空闲cpu数据
  
  wait_cpu    number –等待cpu数据(只是aix存在)
  
  )
  
  tablespace perfstat;
  
  然后,通过UNIX/LINUX的shell变成,利用vmstat的结果来获取相应的服务器信息,并且存放到表中。
  
  关于shell编程,可能已经超出本文内容,并且诚实的说,本人并没有shell编程的经验,希望那位兄台可以完成shell编程的内容,并劳驾mail给我共享一下,谢了先!!
  
  附:
  
  LINUX上VMSTAT的帮助手册:(man vmstat的结果)
  
  VMSTAT(8)     Linux Administrator's Manual     VMSTAT(8)
  
  NAME
  
  vmstat - Report virtual memory statistics
  
  SYNOPSIS
  
  vmstat [-n] [delay [ count]]
  
  vmstat[-V]
  
  DESCRIPTION
  
  vmstat reports information about processes, memory, paging, block IO, traps, and CPU activity.
  
  The first report produced gives averages since the last reboot. Additional reports give information on a sam-
  
  pling period of length delay. The process and memory reports are instantaneous in either case.
  
  Options
  
  The -n switch causes the header to be displayed only once rather than periodically.
  
  delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the
  
  average values since boot.
  
  count is the number of updates. If no count is specified and delay is defined, count defaults to infinity.
  
  The -V switch results in displaying version information.
  
  FIELD DESCRIPTIONS
  
  Procs
  
  r: The number of processes waiting for run time.
  
  b: The number of processes in uninterruptable sleep.
  
  w: The number of processes swapped out but otherwise runnable. This
  
  field is calculated, but Linux never desperation swaps.
  
  Memory
  
  swpd: the amount of virtual memory used (kB).
  
  free: the amount of idle memory (kB).
  
  buff: the amount of memory used as buffers (kB).
  
  Swap
  
  si: Amount of memory swapped in from disk (kB/s).
  
  so: Amount of memory swapped to disk (kB/s).
  
  IO
  
  bi: Blocks sent to a block device (blocks/s).
  
  bo: Blocks received from a block device (blocks/s).
  
  System
  
  in: The number of interrupts per second, including the clock.
  
  cs: The number of context switches per second.
  
  :  CPU
  
  These are percentages of total CPU time.
  
  us: user time
  
  sy: system time
  
  id: idle time
  
  NOTES
  
  vmstat does not require special permissions.
  
  These reports are intended to help identify system bottlenecks. Linux vmstat does not count itself as a run-
  
  ning process.
  
  All blocks are currently 1k, except for CD-ROM blocks which are 2k.
  
  FILES
  
  /proc/meminfo
  
  /proc/stat
  
  /proc/*/stat
  
  SEE ALSO
  
  ps(1), top(1), free(1)
  
  BUGS
  
  Does not tabulate the block io per device or count the number of system calls.
  
  AUTHOR
  
  Written by Henry Ware .
  
  Throatwobbler Ginkgo Labs 27 July 1994         VMSTAT(8)
  
  (待续)
【责编:admin】

--------------------next---------------------

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