solaris檢視I/O、記憶體、網路效能最佳化命令 iostat , vmstat

shilei1發表於2013-02-17
iostat反映了終端、磁碟I/O情況和CPU活動。輸出結果的第一行是從系統啟動到現在為止的這段時間的結果,接下去的每一行是interval時間段內的結果。Kernel裡有一組計數器用來跟蹤這些值。
iostat的預設引數是tdc(terminal, disk, and CPU)。如果任何其他的選項被指定,這個預設引數將被完全替代,例如,iostat -d將只反映磁碟的統計結果。

基本語法: iostat interval count

option - 讓你指定所需資訊的裝置,像磁碟、cpu或者終端(-d , -c , -t or -tdc ) 。x 選項給出了完整的統計結果(gives the extended statistic)。
interval - 在兩個samples之間的時間(秒)。
count - 就是需要統計幾次

示例:

# iostat -xd
                 extended device statistics                
device    r/s    w/s   kr/s   kw/s wait actv  svc_t  %w  %b
sd0       0.2    0.0    3.8    0.1  0.0  0.0    4.3   0   0
sd1       0.0    0.0    0.6    0.0  0.0  0.0   47.0   0   0
sd2       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd3       0.0    0.0    0.6    0.0  0.0  0.0   46.9   0   0
sd4       0.1   63.3    0.6 2538.6 119.4  1.6 1909.8  53  53
ssd2      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd3      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd8      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd11     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd16    40.4   49.5 5139.9 4667.4  0.0  1.1   12.8   0   8
ssd17     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd20     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd21     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd22   211.3   45.6 26994.2 3818.7  0.0  3.6   14.0   0  30
ssd23   211.3   45.5 26992.8 3818.9  0.0  3.6   14.0   0  30

# iostat -xtc 5 2
                 extended device statistics                    tty         cpu
device    r/s    w/s   kr/s   kw/s wait actv  svc_t  %w  %b  tin tout  us sy wt id
sd0       0.2    0.0    3.8    0.1  0.0  0.0    4.3   0   0   17  574   1  1  0 97
sd1       0.0    0.0    0.6    0.0  0.0  0.0   47.0   0   0
sd2       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd3       0.0    0.0    0.6    0.0  0.0  0.0   46.9   0   0
sd4       0.1   63.3    0.6 2539.9 119.4  1.6 1910.3  53  53
ssd2      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd3      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd8      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd11     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd16    40.4   49.5 5139.6 4667.2  0.0  1.1   12.8   0   8
ssd17     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd20     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd21     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd22   211.3   45.6 26993.4 3818.6  0.0  3.6   14.0   0  30
ssd23   211.3   45.4 26992.0 3818.8  0.0  3.6   14.0   0  30
                 extended device statistics                    tty         cpu
device    r/s    w/s   kr/s   kw/s wait actv  svc_t  %w  %b  tin tout  us sy wt id
sd0       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0   42  271   4  1  0 95
sd1       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd2       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd3       0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
sd4       0.0  121.5    0.0 4855.4 291.9  3.0 2426.1 100 100
ssd2      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd3      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd8      0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd11     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd16     0.0   44.1    0.0  635.6  0.0  0.1    1.2   0   1
ssd17     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd20     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd21     0.0    0.0    0.0    0.0  0.0  0.0    0.0   0   0
ssd22    80.7    0.0 10265.4    0.0  0.0  1.1   13.8   0   6
ssd23    75.6    0.0 9657.1    0.0  0.0  1.1   15.1   0   6

disk name of the disk
r/s reads per second
w/s writes per second
Kr/s kilobytes read per second
Kw/s kilobytes written per second
wait average number of transactions waiting for service (Q length)
actv average number of transactions actively
being serviced (removed from the
queue but not yet
completed)
%w percent of time there are transactions waiting
for service (queue non-empty)
%b percent of time the disk is busy (transactions
in progress)

從iostat輸出結果中需要注意的值:

Reads/writes per second (r/s , w/s)
Percentage busy (%b)
Service time (svc_t)

如果磁碟顯示長時間的高reads/writes,並且磁碟的percentage busy (%b)也遠大於5%,同時average service time (svc_t)也遠大於30 milliseconds,這以下的措施需要被執行:
1.)調整應用,令其使用磁碟i/o更加有效率,可以透過修改磁碟佇列、使用應用伺服器的cache

2.)將檔案系統分佈到2個或多個磁碟上,並使用volume manager/disksuite的條帶化特點

3.) 增加系統引數值,如inode cache , ufs_ninode。Increase the system parameter values for inode cache , ufs_ninode , which is Number of inodes to be held in memory. Inodes are cached globally (for UFS), not on a per-file system basis

4.) 將檔案系統移到更快的磁碟/控制器,或者用更好的裝置來代替 

Virtual Memory Statistics ( vmstat )

vmstat - vmstat反映了程式的虛擬記憶體、虛擬記憶體、磁碟、trap(是不是翻譯成中斷??)和cpu的活動情況

在多cpu系統中,vmstat在輸出結果中平均了cpu數量。For per-process statistics .如果沒有選項,vmstat顯示一行虛擬記憶體活動的概要 

 語法:

vmstat interval count

option - 讓你指定所需的資訊型別,例如 paging -p , cache -c ,.interrupt -i etc.

如果沒有指定選項,將會顯示程式、記憶體、頁、磁碟、中斷和cpu資訊

interval - 同iostat

count - 同iostat

示例:

# vmstat 2
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr s0 s1 s2 s3   in   sy   cs us sy id
 8 0 0 13690040 3530888 38 150 0 0 0  0  0  0  0 -0  0 4224 6123 4809  1  1 97
 0 1 0 14582056 994832 8 80  2  2  2  0  0  0  0  0  0 5902 9678 6161  4  4 92
 0 1 0 14579120 992464 43 304 0 0  0  0  0  1  0  0  0 4967 8498 4858  4  3 93
 0 1 0 14579816 994808 221 1325 0 0 0 0  0 23  0  0  0 3807 11072 3660 4  3 93
 0 2 0 14579792 997448 0  0  0  0  0  0  0  0  0  0  0 3827 8948 3581  4  1 94
 0 1 0 14578328 997576 56 302 0 0  0  0  0  0  0  0  0 5607 9484 5916  4  2 93
 0 1 0 14578024 998808 0  0  0  0  0  0  0  0  0  0  0 6020 7387 5992  4  2 93
 0 2 0 14577936 1000328 0 0  0  0  0  0  0  0  0  0  0 4459 7933 4346  4  2 94
 0 1 0 14577680 1000856 0 3  0  0  0  0  0  0  0  0  0 4591 8336 4577  4  2 94
 0 0 0 14577560 1001760 0 19 0  0  0  0  0  0  0  0  0 5445 6626 5838  4  3 93

# vmstat disk
 kthr      memory            page            disk          faults      cpu
 r b w   swap  free  re  mf pi po fr de sr -- -- -- --   in   sy   cs us sy id
 8 0 0 13690104 3530696 38 150 0 0 0  0  0  0  0  0  0 4224 6123 4809  1  1 97

procs
r in run queue
b blocked for resources I/O, paging etc.
w swapped

memory (in Kbytes)
swap - amount of swap space currently available
free - size of the free list

page ( in units per second).
re page reclaims - see -S option for how this field is modified.
mf minor faults - see -S option for how this field is modified.
pi kilobytes paged in
po kilobytes paged out
fr kilobytes freed
de anticipated short-term memory shortfall (Kbytes)
sr pages scanned by clock algorithm

disk ( operations per second )
There are slots for up to four disks, labeled with a single letter and number.
The letter indicates the type of disk (s = SCSI, i = IPI, etc) . The number is
the logical unit number.

faults
in (non clock) device interrupts
sy system calls
cs CPU context switches

cpu - breakdown of percentage usage of CPU time. On multiprocessors this is an a
verage across all processors.
us user time
sy system time
id idle time

問題情況:
1.) 如果processes in run queue (procs r)的數量遠大於系統中cpu的數量,將會使系統便慢。
2.) 如果這個數量是cpu的4倍的話,說明系統正面臨cpu能力短缺,這將使系統執行速度大幅度降低
3.) 如果cpu的idle時間經常為0的話,或者系統佔用時間(cpu sy)是使用者佔用時間(cpu us)兩輩的話,系統面臨缺少cpu資源

解決方案 :
解決這些情況,涉及到調整應用程式,使其能更有效的使用cpu,同時增加cpu的能力或數量。

記憶體問題:
記憶體的瓶頸取決於scan rate (sr) 。scan rate是每秒時鐘對頁的掃描 (he scan rate is the pages scanned by the clock algorithm per second.)如果 scan rate (sr)一直大於200 pages每秒,這時就是記憶體短缺的現實。
解決方案 :
1. 調整應用和伺服器,使其能更好的使用memory和cache
2. 增加系統記憶體

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/196700/viewspace-754185/,如需轉載,請註明出處,否則將追究法律責任。

相關文章