數據庫調優工作中,有一部分是需要排查IO問題的,例如IO的速度或者RAID級別無法響應高并發下的快速請求。最常見的就是查看磁盤每次讀寫的響應速度,通過性能計數器Avg.Disk sec/Read(Write)我們可以很直觀的看到他們。不同的業務,繁忙程度也不同,需要什么樣的IO做支撐?難道都用最高配的IO去配置硬件嗎?能否通過一些經驗和基線來判斷當下磁盤環境是否能滿足需求呢?
手上有4塊 Inter SSD DC S3500 Series 600GB硬盤做成的RAID1兩組,我們就拿它來練練手吧!
SQLIO是微軟提供的一款IO測試工具,下載地址:http://www.microsoft.com/en-us/download/details.aspx?id=20163
下載完畢后,一路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)的影響
測試熱身:
首先,我們先理清幾點 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單位大小
6、SQL Server分配數據的最小單位是8KB,而Windows存儲數據也有最小的分配單位,那就是卷簇,而且該值格式化磁盤分區時是可選的,默認值即為4KB。
![]()
查看指定分區卷簇大小:fsutil fsinfo ntfsinfo d:
![]()
測試過程:
1、兩塊分區分別為D盤和E盤,其中D盤簇大小為默認4KB,E盤簇大小為64KB
2、D盤的測試代碼如下:
Rem 8KB隨機寫sqlio -kW -t8 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t16 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t32 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o2 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o4 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o8 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o16 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtRem 64KB隨機寫sqlio -kW -t8 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t16 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t32 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o2 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o4 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o8 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o16 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtRem 8KB隨機讀sqlio -kR -t8 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t16 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t32 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o1 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o2 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o4 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o8 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o16 -frandom -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtRem 64KB隨機讀sqlio -kR -t8 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t16 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t32 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o1 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o2 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o4 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o8 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kR -t64 -s90 -dD -o16 -frandom -b64 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtRem 8KB順序寫sqlio -kW -t8 -s90 -dD -o1 -fsequential -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t16 -s90 -dD -o1 -fsequential -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t32 -s90 -dD -o1 -fsequential -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o1 -fsequential -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW -t64 -s90 -dD -o2 -fsequential -b8 -BH -LS Testfile.dat >>4KB_Cluster_Test.txtsqlio -kW
新聞熱點
疑難解答