天天看點

SQL Server 伺服器磁盤測試之SQLIO篇

      資料庫調優工作中,有一部分是需要排查IO問題的,例如IO的速度或者RAID級别無法響應高并發下的快速請求。最常見的就是檢視磁盤每次讀寫的響應速度,通過性能計數器Avg.Disk sec/Read(Write)我們可以很直覺的看到他們。不同的業務,繁忙程度也不同,需要什麼樣的IO做支撐?難道都用最高配的IO去配置硬體嗎?能否通過一些經驗和基線來判斷當下磁盤環境是否能滿足需求呢?

下載下傳完畢後,一路Next安裝完畢,預設目錄是:C:\Program Files (x86)\SQLIO

前期準備工作:

1、為SQLIO.exe排除資料執行保護

2、去掉圖示上的勾

下面我們來熟悉一下SQLIO的參數:

-o

Number of outstanding I/O requests per thread. When attempting to determine the capacity of a given volume or set of volumes, start with a reasonable number for this and increase until disk saturation is reached (that is, latency starts to increase without an additional increase in throughput or IOPs). Common values for this are 8, 16, 32, 64, and 128.

Keep in mind that this setting is the number of outstanding I/Os per thread.

每個線程可以發起多個IO請求

-LS

Instructs SQLIO to capture disk latency information. Capturing latency data is recommended when testing a system.

開啟該參數列印出磁盤延遲資訊,必選項。

-k

Specify either R or W (read or write). Both reads and writes should be tested. Keep in mind that the storage array cache may absorb a good amount of write activity and potentially skew results. Ensure that the duration is long enough to saturate the cache in order to get a true measure of storage capacity.

指定讀操作-R或者寫操作W

-s

Duration of test (in seconds). For initial tests, running for 5-10 minutes per I/O size is recommended to get a good idea of I/O performance.

每個批次執行的時間,推薦每個size的IO請求運作5-10分鐘,機關為秒

-b

Size of the I/O request in kbytes. For random I/O, 8 KB and 64 KB are as many values as are need to be tested. The most common random I/O size for SQL Server is 8 KB. For random I/O, pay close attention to the number of I/Os per second and latency. For sequential I/O, test a range of sizes (4, 8, 16, 32, 64, 128, 256) and pay attention to throughput and latency.

指定讀寫的IO大小,機關是KB。8KB是SQL Server随機讀寫最常用的塊大小,其次是64KB。

對于随機IO測試,密切注意每秒的IO請求數和延遲;

對于順序IO測試,多注意每秒的吞吐量和延遲。

-f

Type of I/O to issue. Either ‘random’ or ‘sequential’.

指定IO的請求方式,随機Random或者順序Sequential

-F

Name of the file that will contain a list of the test file(s) used by SQLIO.

指定SQLIO測試使用的檔案

測試目的:

檢視不同的卷簇大小(預設4KB/64KB)對SQL Server常用IO操作機關(8KB/64KB)的影響 <a href="http://114.215.103.21/wp-content/uploads/2014/04/QQ20140410103912.png"></a>

測試熱身:

首先,我們先理清幾點 Keep in your mind: 1、對于随機Random讀寫,我們看重的是每秒的IO操作次數,即 IO/sec,IO Operations 2、對于順序Sequential讀寫,我們看重的是每秒的吞吐量,即 MB/sec 3、對于SQL Server資料檔案,更多的操作是随機讀寫。 讀:SQL Server應用戶端查詢需求,将不在記憶體中的記錄從磁盤上随機的位置讀入記憶體;寫:SQL Server CheckPoint或者Lazy Writer出動時,将SQL Server Buffer Cache中大量的Dirty Page寫入磁盤上随機的位置。 4、對于SQL Server日志檔案,更多的操作是順序讀寫。 讀:當進行日志備份或者LogReader工作時,SQL Server将順序的讀取日志。 寫:順序寫操作是日志的再正常不過的行為了 5、如下表格,列出了SQL Server常見行為下的IO操作機關大小,可以看到,8KB和64KB依次是SQL Server最常操作的IO機關大小 <a href="http://114.215.103.21/wp-content/uploads/2014/04/QQ20140415103655.png"></a>
6、SQL Server配置設定資料的最小機關是8KB,而Windows存儲資料也有最小的配置設定機關,那就是卷簇,而且該值格式化磁盤分區時是可選的,預設值即為4KB。 <a href="http://114.215.103.21/wp-content/uploads/2014/04/QQ20140415103153.png"></a> 檢視指定分區卷簇大小:fsutil fsinfo ntfsinfo d: <a href="http://114.215.103.21/wp-content/uploads/2014/04/QQ20140415104414.png"></a> 測試過程:         1、兩塊分區分别為D盤和E盤,其中D盤簇大小為預設4KB,E盤簇大小為64KB          2、D盤的測試代碼如下:

3、E盤測試腳本: