ORACLE性能診斷―學習statspack筆記(四)[擴展statspack收集服務器統計]

ORACLE性能診斷―學習statspack筆記(四)[擴展statspack收集服務器統計]<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

作者:劉穎博

時間: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滿負荷

首先需要聲明一點的是,vmstatCPU的度量是百分比的。當ussy的值接近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/LINUXshell變成,利用vmstat的結果來獲取相應的服務器信息,並且存放到表中。

 

關於shell編程,可能已經超出本文內容,並且誠實的說,本人並沒有shell編程的經驗,希望那位兄臺可以完成shell編程的內容,並勞駕mail給我共享一下,謝了先!!

 

 

 

 

附:

LINUXVMSTAT的幫助手冊:(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 <[email protected]>.

 

Throatwobbler Ginkgo Labs 27 July 1994                  VMSTAT(8)

 

 

(待續)

……………………………………………………………………………………

參考

Donald K.BurlesonORACLE HIGH-PERFORMANCE TUNING WITH STATSPACK

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章