国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux硬盤性能檢測

2024-06-28 13:23:32
字體:
來源:轉載
供稿:網友
linux硬盤性能檢測

對于現在的計算機來講,整個計算機的性能主要受磁盤IO速度的影響,內存、CPU包括主板總線的速度已經很快了。

基礎檢測方法1、dd命令

dd命令功能很簡單,就是從一個源讀取數據以bit級的形式寫到一個目標地址,通過這種方式我們就可以檢測我們實際磁盤在linux系統中的讀寫性能,不需要經過任何檢測軟件而就是去讀取數據,一般來講用dd來檢測磁盤的性能也被認為是最接近真實情況。

用法:dd if[數據從哪里讀取,一般來講從dev下的zero設備,這個設備不斷返回0作為數據源] of[把讀取的文件寫入哪個文件] bs[block size,每次讀寫基本快的大小] count[總共讀寫多少個bs] conv=fdatasync[在linux中有很強的內存緩存機制,為了提高系統性能,linux會大量使用內存作為硬盤讀寫緩存,所以這里用這個參數來保證數據是直接寫入硬盤]

示例:

dd if=/dev/zero of=testfile bs=1M count=512 conv=fdatasync

在我的虛擬機上結果如下:

[root@localhost ~]# dd if=/dev/zero of=testfile bs=1M count=512 conv=fdatasync512+0 records in512+0 records out536870912 bytes (537 MB) copied, 19.6677 s, 27.3 MB/s

一般建議多次運行這個命令取平均值,在每次執行上面的命令前,建議用下面的命令來清除緩存:

echo 3 > /PRoc/sys/vm/drop_caches

通過dd命令測試往往不是很嚴謹也不是很科學,因為可能會受cpu使用率和后臺服務影響。

2、hdparm命令

hdparm命令專門用來去獲取修改測試磁盤信息。hdparm必須在管理員權限下運行。

用法:hdparm -t 要測試的磁盤

示例:

# hdparm -t /dev/sda

結果:

[root@localhost ~]# hdparm -t /dev/sda/dev/sda: Timing buffered disk reads: 444 MB in  3.01 seconds = 147.35 MB/sec[root@localhost ~]# hdparm -t /dev/sda/dev/sda: Timing buffered disk reads: 808 MB in  3.00 seconds = 269.21 MB/sec

可以看到兩次運行結果差距比較大,所以建議多次運行取平均值。

用這兩種方式測試出來的結果是非常簡單,專業測試磁盤性能時,不僅需要知道讀寫性能,還要區分讀寫數據大?。?k/16k/32k),還要測試是順序讀寫還是隨機讀寫,如果是機械硬盤還要測試內磁道和外磁道的速率差距等等。

高級檢測方法1、bonnie++

可通過yum安裝(不包含在linux默認的yum源中,建議安裝repoforge源):

yum install -y bonnie++

用法:bonnie++ -u 用戶名 -s 測試讀寫文件大小

示例:

bonnie++ -u root -s 2g

默認情況下,會寫一個4G大小的文件,分為4份,會通過讀寫隨機操作對系統IO進行全面測試,由于寫的文件比較大,所以時間會比較長。

結果:

[root@localhost ~]# bonnie++ -u root -s 2gUsing uid:0, gid:0.Writing a byte at a time...doneWriting intelligently...doneRewriting...doneReading a byte at a time...doneReading intelligently...donestart 'em...done...done...done...done...done...Create files in sequential order...done.Stat files in sequential order...done.Delete files in sequential order...done.Create files in random order...done.Stat files in random order...done.Delete files in random order...done.Version  1.96       ------Sequential Output------ --Sequential Input- --Random-Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CPlocalhost.locald 2G   287  99 31885  20 59035  15  2795  99 514292  64  9491 421Latency             42230us    2804ms     284ms    8198us    5820us    4819usVersion  1.96       ------Sequential Create------ --------Random Create--------localhost.localdoma -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP                 16 20946  92 +++++ +++ +++++ +++ 23169  94 +++++ +++ +++++ +++Latency              2539us     853us     993us    1675us     284us    1234us1.96,1.96,localhost.localdomain,1,1414376948,2G,,287,99,31885,20,59035,15,2795,99,514292,64,9491,421,16,,,,,20946,92,+++++,+++,+++++,+++,23169,94,+++++,+++,+++++,+++,42230us,2804ms,284ms,8198us,5820us,4819us,2539us,853us,993us,1675us,284us,1234us

這個格式實在有點亂,不過好在這個軟件還提供了把結果轉換成html表格的工具(用最后一行轉換):

echo 1.96,1.96,localhost.localdomain,1,1414376948,2G,,287,99,31885,20,59035,15,2795,99,514292,64,9491,421,16,,,,,20946,92,+++++,+++,+++++,+++,23169,94,+++++,+++,+++++,+++,42230us,2804ms,284ms,8198us,5820us,4819us,2539us,853us,993us,1675us,284us,1234us | bon_csv2html >> bon_result.html

bon_result.html的顯示如下:

這個就好看多了,簡單解釋一下:

Sequential Output(順序輸出,實際是寫操作)下的 Per Char是值用putc方式寫,毫無疑問,因為cache的line總是大于1字節的,所以不停的騷擾CPU執行putc,看到cpu使用率是99%.寫的速度是0.3MB/s,非常慢了。

Sequential Output下的block是按照block去寫的,明顯CPU使用率就下來了,速度也上去了,是31MB/s,跟上面用dd測試的差不多。

Sequential Input(順序輸入,實際是讀操作)下的Per Char是指用getc的方式讀文件,速度是2.5MB/s,CPU使用率是99%。

Sequential Input下的block是指按照block去讀文件,速度是50MB/s,CPU使用率是64%。

Random Seeks是隨機尋址,每秒尋址9000多次還算可以的。

Sequential Create(順序創建文件)

Random Create(隨機創建文件)

有的結果是很多+號,這表示bonner++認為值不可靠,于是不輸出。一般來說是因為執行的很快,一般來說不是系統瓶頸,所以不用擔心。

2、iozone

iozone提供的信息更全面和精確,所以iozone是系統性能測試中用的最多的工具之一。

iozone使用略復雜,這里只用最常用的一些參數:

-l:最小的進程數量,用于并發測試,不想測多進程可以設置為1。

-u:最大的進程數量,用于并發測試,不想測多進程可以設置為1。

-r:默認讀寫基本單位,如16k,這個值一般跟測試的應用有關,如要測試數據庫,這個值就跟數據庫的塊大小一致。

-s:默認讀寫的大小,建議這個值大一些(一般為2倍內存大?。?,因為iozone并不會規避低層的緩存,所以如果值比較小,可能直接在內存中就完成了。

-F:指定緩存文件

示例:

iozone -l 1 -u 1 -r 16k -s 2g -F tempfile

結果:

Children see throughput for  1 initial writers  =   31884.46 kB/secParent sees throughput for  1 initial writers   =   30305.05 kB/secMin throughput per process          =   31884.46 kB/sec Max throughput per process          =   31884.46 kB/secAvg throughput per process          =   31884.46 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for  1 rewriters    =  102810.49 kB/secParent sees throughput for  1 rewriters     =   95660.98 kB/secMin throughput per process          =  102810.49 kB/sec Max throughput per process          =  102810.49 kB/secAvg throughput per process          =  102810.49 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for  1 readers      =  450193.59 kB/secParent sees throughput for  1 readers       =  450076.28 kB/secMin throughput per process          =  450193.59 kB/sec Max throughput per process          =  450193.59 kB/secAvg throughput per process          =  450193.59 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 re-readers    =  451833.53 kB/secParent sees throughput for 1 re-readers     =  451756.47 kB/secMin throughput per process          =  451833.53 kB/sec Max throughput per process          =  451833.53 kB/secAvg throughput per process          =  451833.53 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 reverse readers   =   61854.02 kB/secParent sees throughput for 1 reverse readers    =   61851.88 kB/secMin throughput per process          =   61854.02 kB/sec Max throughput per process          =   61854.02 kB/secAvg throughput per process          =   61854.02 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 stride readers    =   43441.66 kB/secParent sees throughput for 1 stride readers     =   43439.83 kB/secMin throughput per process          =   43441.66 kB/sec Max throughput per process          =   43441.66 kB/secAvg throughput per process          =   43441.66 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 random readers    =   47707.72 kB/secParent sees throughput for 1 random readers     =   47705.00 kB/secMin throughput per process          =   47707.72 kB/sec Max throughput per process          =   47707.72 kB/secAvg throughput per process          =   47707.72 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 mixed workload    =   50807.69 kB/secParent sees throughput for 1 mixed workload     =   50806.24 kB/secMin throughput per process          =   50807.69 kB/sec Max throughput per process          =   50807.69 kB/secAvg throughput per process          =   50807.69 kB/secMin xfer                    = 2097152.00 kBChildren see throughput for 1 random writers    =   45131.93 kB/secParent sees throughput for 1 random writers     =   43955.32 kB/secMin throughput per process          =   45131.93 kB/sec Max throughput per process          =   45131.93 kB/secAvg throughput per process          =   45131.93 kB/secMin xfer                    = 2097152.00 kB

從上面的結果中可以看到各種方式下系統磁盤的讀寫性能。

PS:其實下面還有結果,只是我的虛擬機磁盤滿了,崩潰了。

參考文檔

1、Linux硬盤性能檢測

2、了解你的磁盤之使用bonnie++測試磁盤性能


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 静乐县| 丰宁| 五家渠市| 旬邑县| 高州市| 咸阳市| 嘉荫县| 黑水县| 清原| 盱眙县| 明星| 华蓥市| 明水县| 新乡县| 牟定县| 东莞市| 辉南县| 伽师县| 长治县| 乌拉特前旗| 松原市| 甘肃省| 江安县| 梓潼县| 丰镇市| 宁陕县| 博爱县| 清涧县| 民权县| 五原县| 上思县| 黎城县| 诸暨市| 耒阳市| 阿克苏市| 新河县| 房山区| 清水河县| 基隆市| 容城县| 永福县|