Total DISK READ: 3.89 K/s | Total DISK WRITE: 0.00 B/s TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND 14060 be/2 root 3.89 K/s 0.00 B/s 0.00 % 0.09 % AliYunDun 14695 be/4 www 0.00 B/s 89.42 K/s 0.00 % 0.00 % nginx: worker process 14697 be/4 www 0.00 B/s 256.61 K/s 0.00 % 0.00 % nginx: worker process 14698 be/4 www 0.00 B/s 38.88 K/s 0.00 % 0.00 % nginx: worker process 14699 be/4 www 0.00 B/s 66.10 K/s 0.00 % 0.00 % nginx: worker process 1 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % init 2 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [kthreadd] 3 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/0] 4 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/0] 5 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [stopper/0] 6 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/0] 7 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/1] 8 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [stopper/1] 9 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/1] 10 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/1] 11 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/2] 12 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [stopper/2] 13 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/2] 14 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/2] 15 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/3] 16 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [stopper/3] 17 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [ksoftirqd/3] 18 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [watchdog/3] 19 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [migration/4] 20 rt/4 root 0.00 B/s 0.00 B/s 0.00 % 0.00 % [stopper/4]
[root@test ~]# sar -b 1 10 Linux 2.6.32-573.22.1.el6.x86_64 (test) 01/08/2019 _x86_64_ (8 CPU) 06:10:37 PM tps rtps wtps bread/s bwrtn/s 06:10:38 PM 273.47 4.08 269.39 32.65 10195.92 06:10:39 PM 4.08 2.04 2.04 16.33 16.33 06:10:40 PM 4.12 2.06 2.06 16.49 16.49 06:10:41 PM 3.09 3.09 0.00 24.74 0.00 06:10:42 PM 12.00 4.00 8.00 32.00 560.00 06:10:43 PM 263.92 2.06 261.86 16.49 10169.07 06:10:44 PM 4.17 4.17 0.00 125.00 0.00 06:10:45 PM 3.09 3.09 0.00 49.48 0.00 06:10:46 PM 2.08 2.08 0.00 16.67 0.00 06:10:47 PM 3.09 2.06 1.03 16.49 404.12 Average: 57.45 2.88 54.57 34.53 2141.83
說明:nginx
tps: 每秒向磁盤設備請求數據的次數,包括讀、寫請求,爲rtps與wtps的和。出於效率考慮,每一次IO下發後並非當即處理請求,而是將請求合併(merge),這裏tps指請求合併後的請求計數。緩存
rtps: 每秒向磁盤設備的讀請求次數bash
wtps: 每秒向磁盤設備的寫請求次數async
bread: 每秒從磁盤讀的bytes數量工具
bwrtn: 每秒向磁盤寫的bytes數量測試
[root@test ~]# blockdev --getbsz /dev/vda1 4096
blocksize是4KB大小操作系統
[root@iZ23e3f2jdcZ ~]# time dd if=/dev/zero of=test.dbf bs=4K count=50000 oflag=direct 50000+0 records in 50000+0 records out 204800000 bytes (205 MB) copied, 35.9065 s, 5.7 MB/s real 0m35.908s user 0m0.099s sys 0m1.797s [root@iZ23e3f2jdcZ ~]# time dd if=/dev/zero of=test.dbf bs=4K count=50000 50000+0 records in 50000+0 records out 204800000 bytes (205 MB) copied, 1.09874 s, 186 MB/s real 0m1.103s user 0m0.025s sys 0m0.254s [root@iZ23e3f2jdcZ ~]# time dd if=/dev/vda1 of=/dev/null bs=4K count=50000 50000+0 records in 50000+0 records out 204800000 bytes (205 MB) copied, 1.49831 s, 137 MB/s real 0m1.500s user 0m0.021s sys 0m0.180s [root@test ~]# hdparm -Tt /dev/vda1 /dev/vda1: Timing cached reads: 19468 MB in 1.99 seconds = 9766.52 MB/sec Timing buffered disk reads: 384 MB in 3.00 seconds = 127.88 MB/sec
這是一個是用來獲取ATA/IDE硬盤的參數的命令,是由早期Linux IDE驅動的開發和維護人員 Mark Lord開發編寫的( hdparm has been written by Mark Lord <mlord@pobox.com>, the primary developer and maintainer of the (E)IDE driver for Linux, with suggestions from many netfolk).該命令應該也是僅用於Linux系統,對於UNIX系統,ATA/IDE硬盤用的可能比較少,通常大型的系統都是使用磁盤陣列的blog
使用方法很簡單ip
hdparm -Tt /dev/vda1
能夠看到,2秒鐘讀取了19468MB的緩存,約合9766.52MB/sec,在3.11秒中讀取了384MB磁盤(物理讀),讀取速度約合127.88 MB/sec開發
這不是一個專業的測試工具,不過若是對於測試結果的要求不是很苛刻的話,平時能夠使用來對磁盤的讀寫速度做一個簡單的評估,另外因爲這是一個免費軟件,基本上×NIX系統上都有安裝,對於Oracle裸設備的複製遷移,dd工具通常都是首選.
首先了解兩個特殊設備
/dev/null 僞設備,回收站.寫該文件不會產生IO
/dev/zero 僞設備,會產生空字符流,對它不會產生IO
a.測試磁盤的IO寫速度
time dd if=/dev/zero of=test.dbf bs=4k count=300000 # 若是要測試實際速度 還要在末尾加上 oflag=direct測到的纔是真實的IO速度
b.測試磁盤的IO讀速度
dd if=test.dbf bs=4k count=300000 of=/dev/null #表示 每次寫入/讀取8k的數據,執行300000次
功能說明:讀取,轉換並輸出數據。
語法:dd [bs=<字節數>][cbs=<字節數>][conv=<關鍵字>][count=<區塊數>][ibs=<字節數>][if=<文件>][obs=<字節數>][of=<文件>][seek=<區塊數>][skip=<區塊數>][--help][--version]
補充說明:dd可從標準輸入或文件讀取數據,依指定的格式來轉換數據,再輸出到文件,設備或標準輸出。
參數:
bs=<字節數> 將ibs( 輸入)與obs(輸出)設成指定的字節數。
cbs=<字節數> 轉換時,每次只轉換指定的字節數。
conv=<關鍵字> 指定文件轉換的方式。
count=<區塊數> 僅讀取指定的區塊數。
ibs=<字節數> 每次讀取的字節數。
if=<文件> 從文件讀取。
obs=<字節數> 每次輸出的字節數。
of=<文件> 輸出到文件。
seek=<區塊數> 一開始輸出時,跳過指定的區塊數。
skip=<區塊數> 一開始讀取時,跳過指定的區塊數。
--help 幫助。
--version 顯示版本信息。
if=xxx 從xxx讀取,如if=/dev/zero,該設備無窮盡地提供0,(不產生讀磁盤IO)
of=xxx 向xxx寫出,能夠寫文件,能夠寫裸設備。如of=/dev/null,"黑洞",它等價於一個只寫文件. 全部寫入它的內容都會永遠丟失. (不產生寫磁盤IO)
bs=8k 每次讀或寫的大小,即一個塊的大小。
count=xxx 讀寫塊的總數量。
避免操做系統「寫緩存」干擾測試成績,使用sync、fsync、fdatasync