天天看点

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盘测试脚本: