ORACLE性能诊断―学习statspack笔记(四)[扩展statspack收集服务器统计]

** ORACLE ** ** 性能诊断―学习 statspack ** ** 笔记(四) [ ** ** 扩展statspack收集服务器统计 ] **


** 作者:刘颖博 **

** 时间: 2004-3-22 **

** mail ** ** : [email protected] ** ** ,请指正 **


** 转载请注明出处及作者 **

** 说明 ** :由于 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 ,出现内存争用现象是 Oracle 的常见问题。

首先察看 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 linux 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

 1<[email protected]>. 
 2
 3Throatwobbler Ginkgo Labs 27 July 1994  VMSTAT(8) 
 4
 5** **
 6
 7(待续) 
 8
 9…………………………………………………………………………………… 
10
11** 参考  **
12
13Donald K.Burleson  《  ORACLE HIGH-PERFORMANCE TUNING WITH STATSPACK  》</[email protected]>
Published At
Categories with 数据库类
Tagged with
comments powered by Disqus