您好,登錄后才能下訂單哦!
I/O子系統(tǒng)是SQL Server性能的重要組成部分。當我們?yōu)镾QL Server配置一臺新的服務(wù)器,或者添加或修改已有系統(tǒng)的磁盤配置時,都需要判斷I/O子系統(tǒng)的性能。
測試I/O讀寫的塊大小,需要區(qū)分順序讀寫與隨機讀寫(sequential/random)。
(1)順序I/O
對于順序I/O,塊大小應(yīng)當包括 8 KB、64 KB、128 KB、256 KB、1024 KB。這是因為SQL Server企業(yè)版的“預(yù)讀”Read-ahead 最高可達到1024KB。測量結(jié)果主要關(guān)注于磁盤的吞吐量(throughput),計量單位為MB/s 。
(2)隨機I/O
對于隨機I/O,一般僅關(guān)注于 8 KB的塊。測量結(jié)果主要關(guān)注于磁盤的尋道能力,計量單位為I/Os per second(IOPs)。
對于OLTP,有以下特點:
(1)OLTP處理在本質(zhì)上一般是對數(shù)據(jù)文件(mdf和ndf)隨機的讀與寫。
(2)在大多數(shù)情況下,從本質(zhì)上來說,讀的活動是持續(xù)的。
(3)對數(shù)據(jù)文件的寫的活動,主要是檢查點(checkpoint)時才發(fā)生。檢查點的頻率是由恢復(fù)間隔設(shè)置(recovery interval settings)決定的。
(4)事務(wù)日志的寫,從本質(zhì)上說,是連續(xù)的、無固定大小的,依賴于工作負荷的性質(zhì)(sector aligned up to 60 KB)。
(5)事務(wù)日志的讀,從本質(zhì)上說,是連續(xù)的(sector aligned up to 120 KB)。
Microsoft官方針對SQL Server 2005發(fā)布了一個最佳實踐的白皮書,推薦以下3種工具。 http://technet.microsoft.com/zh-cn/library/cc966412.aspx
一、SQLIO
1. 安裝SQLIO
SQLIO是Microsoft官方的硬盤壓力測試工具,用于測試磁盤的IOPS(Input/Output per second)值。此工具盡管并不是針對SQL Server工作模式來設(shè)計的,但是仍然可以用來診斷與SQL Server相關(guān)的一些I/O類型的性能,可以測量磁盤的IOPs、吞吐量 (MB/s)和延遲時間。
首先需要到微軟的官網(wǎng)下載 SQLIO Disk Subsystem Benchmark Tool http://www.microsoft.com/en-us/download/details.aspx?id=20163 (本文附件即是)
下載后在運行SQLIO.msi文件,進入安裝向?qū)А?/p>
2. 配置參數(shù)文件
打開安裝所在的文件夾。用文本編輯工具修改param.txt,例如:
f:\testfile.dat 2 0x0 300 #d:\testfile.dat 2 0x0 100 |
每一行都有4個參數(shù),分別為:
(1)Path to test file。測試用的文件和它的完整路徑。上例表示要測試F盤的IOPS,并在F盤生成一個名為testfile.dat的測試文件。
(2)Number of threads (per test file)。測試時,同時使用多少個線程。建議和CPU的數(shù)量一致。
(3)Mask。始終為0x0 。
(4)Size of test file in MB。生成的一個測試文件的大小。
3. 運行測試
運行“命令提示符”,轉(zhuǎn)到SQLIO的安裝路徑,運行以下命令(區(qū)分大小寫):
sqlio -kR -s360 -frandom -o8 -b8 -LS -Fparam.txt |
詳細的參數(shù)如下:
-k<R|W> | kind of IO (R=reads, W=writes) |
-t<threads> | number of threads |
-s<secs> | number of seconds to run |
-d<drive1>..<driveN> | use same filename on each drive letter given |
-R<drive1>,,<driveN> | raw drive letters/number on which to run |
-f<stripe factor> | stripe size in blocks, random, or sequential |
-p[I]<cpu affinity> | cpu number for affinity (0 based)(I=ideal) |
-a[R[I]]<cpu mask> | cpu mask for (R=roundrobin (I=ideal)) affinity |
-o<#outstanding> | depth to use for completion routines |
-b<io size(KB)> | IO block size in KB |
-i<#IOs/run> | number of IOs per IO run |
-m<[C|S]><#sub-blks> | do multi blk IO (C=copy, S=scatter/gather) |
-L<[S|P][i|]> | latencies from (S=system, P=processor) timer |
-U[p] | report system (p=per processor) utilization |
-B<[N|Y|H|S]> | set buffering (N=none, Y=all, H=hdwr, S=sfwr) |
-S<#blocks> | start I/Os #blocks into file |
-v1.1.1 | I/Os runs use same blocks, as in version 1.1.1 |
-64 | use 64 bit memory operations |
-F<paramfile> | read parameters from <paramfile> |
Defaults:
-kR -t1 -s30 -f64 -b2 -i64 -BN testfile.dat
Maximums:
-t (threads): 256
no. of files, includes -d & -R: 256
filename length: 256
4. 查看結(jié)果
C:\Program Files\SQLIO>sqlio -kR -s360 -frandom -o8 -b8 -LS -Fparam.txt sqlio v1.5.SG using system counter for latency timings, 14318180 counts per second parameter file used: param.txt file F:\testfile.dat with 2 threads (0-1) using mask 0x0 (0) 2 threads reading for 360 secs from file F:\testfile.dat using 8KB random IOs enabling multiple I/Os per thread with 8 outstanding size of file F:\testfile.dat needs to be: 314572800 bytes current file size: 0 bytes need to expand by: 314572800 bytes expanding F:\testfile.dat ... done. using specified size: 300 MB for file: F:\testfile.dat initialization done CUMULATIVE DATA: throughput metrics: IOs/sec: 2209.73 MBs/sec: 73.51 latency metrics: Min_Latency(ms): 0 Avg_Latency(ms): 0 Max_Latency(ms): 107 histogram: ms: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24+ %: 98 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
重點關(guān)注輸出結(jié)果中的IOs/sec和MBs/sec的值。
5. 注意事項
(1)虛擬機中的測試結(jié)果將是虛假的,因為虛擬機的硬盤映像文件的緩存機制很復(fù)雜。
(2)如果存儲設(shè)備(SAN或RAID)有緩存,則param.txt文件中Size of test file in MB值必須為讀寫緩存的2倍至4倍。
(3)需要使用各種不同的參數(shù)測試。示例腳本如下:
::Test randmon IO's of 8K call sqlio -kW -s600 -frandom -o32 -b8 -LS -Fparam.txt call sqlio -kR -s600 -frandom -o32 -b8 -LS -Fparam.txt ::Test small sequential writes call sqlio -kW -s60 -fsequential -o1 -b4 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o1 -b8 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o1 -b16 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o1 -b32 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o1 -b64 -LS -Fparam.txt ::Test large sequential read/write call sqlio -kR -s60 -fsequential -o8 –b8 -LS -Fparam.txt call sqlio -kR -s60 -fsequential -o8 -b64 -LS -Fparam.txt call sqlio -kR -s60 -fsequential -o8 -b128 -LS -Fparam.txt call sqlio -kR -s60 -fsequential -o8 -b256 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o8 –b8 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o8 -b64 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o8 -b128 -LS -Fparam.txt call sqlio -kW -s60 -fsequential -o8 -b256 -LS -Fparam.txt |
二、SQLIOSim
1. 簡介
SQLIOSim 用于驗證加壓后的I/O子系統(tǒng)的基本功能。此工具試圖模擬實際的 SQL Server I/O 模式(隨機讀寫數(shù)據(jù)文件、連續(xù)讀寫日志文件)并檢查結(jié)果的正確性。此工具通常用于隔離 SQL Server 的硬件相關(guān)問題。
此工具默認隨SQL Server同時安裝,也可以到官網(wǎng)下載。有2個文件,一個是命令行工具,另一個是圖形界面工具。
2. 圖形界面
(1)配置測試文件用配置參數(shù)
“以管理員身份運行”打開圖形工具。首先出現(xiàn)“File and Configuration”界面。默認會為每一個磁盤驅(qū)動器創(chuàng)建2個文件,分別模擬SQL Server的數(shù)據(jù)文件和日志文件。在下例中,修改其中一個數(shù)據(jù)文件的配置。為了自動刪除測試文件,我們還要選擇“Delete Files At Shutdown”。
(2)測試
完成了上述配置,就回到主界面。點一下工具欄的綠色的“Start”開始測試。
測試完成后,會出現(xiàn)一個提示。
本例中出現(xiàn)4個警告,原因為:
(3)查看結(jié)果
在最終結(jié)果的匯總列表中,找到剛才修改的那個測試文件相應(yīng)的結(jié)果。
Test cycle complete Stopping simulation Closing file F:\sqliosim.mdx ********** Final Summary for file F:\sqliosim.mdx ********** File Attributes: Compression = No, Encryption = No, Sparse = No Target IO Duration (ms) = 100, Running Average IO Duration (ms) = 15, Number of times IO throttled = 1071, IO request blocks = 29 Reads = 2460, Scatter Reads = 2372, Writes = 31, Gather Writes = 3238, Total IO Time (ms) = 422837 DRIVE LEVEL: Sector size = 512, Cylinders = 5221, Media type = 0, Sectors per track = 12, Tracks per Cylinders = 63 DRIVE LEVEL: Read cache enabled = No, Write cache enabled = No DRIVE LEVEL: Read count = 4832, Read time = 20463, Write count = 8953, Write time = 428171, Idle time = 168697, Bytes read = 809762816, Bytes written = 1140978176, Split IO Count = 0, Storage number = 2, Storage manager name = VOLMGR Closing file F:\sqliosim.ldx |
3. 命令行
命令行一共有6個參數(shù)。詳細用法見 http://support.microsoft.com/kb/231619
-cfg file | Override the Sqliosim.cfg.ini default configuration file. The SQLIOSim utility returns an error if the utility cannot find the file. |
-save file | Save the resulting configuration in the configuration file. You can use this option to create the initial configuration file. |
-log file | Specify the error log file name and the error log file path. The default file name is Sqliosim.log.xml. |
-dir dir | Set the location to create the data (.mdf) file and the log (.ldf) file. You can run this command multiple times. In most cases, this location is a drive root or a volume mount point. This location can be a long path or a UNC path. |
-d seconds | Set the duration of the main run. This value excludes the preparation phase and the verification phase. |
-size MB | Set the initial size of the data file in megabytes (MB). The file can grow up to two times the initial size. The size of the log file is calculated as half the size of the data file. However, the log file cannot be larger than 50 MB. |
三、IOMeter
這是一個第三方的工具,詳情請見 http://www.iometer.org/
本文結(jié)語:
通過一些磁盤壓力測試工具,測試磁盤的性能。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。