介绍
vscsiStats是排除虚拟机存储性能问题非常强大的工具,它工作在内核的虚拟SCSI设备层(virtual SCSI device level),这就意味着它能够针对各种存储类型虚拟磁盘(vmdk)进行性能数据的收集,如本地存储,光纤通道存储,NFS,iSCSI等。它支持收集ioLength, seekDistance, outstandingIOs, latency, interarrival性能参数。vscsiStats在ESXi架构中的位置参见下图:
vscsiStats支持收集以下的性能数据统计信息:
interarrival - 虚拟机磁盘操作命令之间的时间间隔,单位us(is the amount of time in microseconds between virtual machine disk commands)
ioLength - I/O大小(is the size of the I/O)
latency - I/O时延(the time of the I/O trip)
outstandingIOs – 当前I/O队列信息(This will help give you an idea of any queuing that is occurring)
seekDistance – The distance in logical block numbers (LBN) that the disk head must travel to read or write a block. If a concentration of your seek distance is very small (less than 1), then the data is sequential in nature. If the seek distance happens to be varied, your level of randomization may be proportional to this distance travelled.
如何使用
此命令从ESXi 4.1开始引入,可以在ESXi shell或DCUI模式下使用。
~ # vscsiStats
VscsiStats -- This tool controls vscsi data collection for virtual machine disk
disk I/O workload characterization. Users can start and stop online data
data collection for particular VMs as well as print out online histogram data.
Command traces can also be collected and printed.
The following histogram related options are available:
-h, --help will print the usage
-l, --list will list the available virtual machines and their virtual disks
-r, --reset will reset the stats
-s, --start will start vscsiStats collection; exclusive of -x
-x, --stop will stop vscsiStats collection; exclusive of -s
-w <worldgroup id>, --worldgroupid specifies a worldID to use for this operation
-i <handle id>, --handleid specifies a vscsi handleID to use for this operation
requires the -w option
-p <histoType>, --printhistos will print out the current histograms for the specified
histogram type. May be used in conjunction with -w and -i.
histoType must be one and only one of:
all, ioLength, seekDistance, outstandingIOs, latency, interarrival
-c, --csv will use comma as delimiter in conjunction with -p
The following command trace related options are available:
-t, --tracecmds will start scsi cmd traces; in conjunction with -s
Note:- the -t option consumes significant system resources so
enabling it indefinitely is not advisable
- try to limit the #virtual disk for which cmd tracing is enabled at any
given time by using --worldgroupid and/or --handleid options.
- trace contains NO customer sensitive data
- only information recorded is:
- serialnumber, IO block size, number of scatter-gather elements
- command type, block number, timestamp
- Therefore, actual data/payload of commands is not stored
- If successfully started, log channel id(s) will be printed out.
To store the command trace in a file for later processing, invoke:
$ logchannellogger <log_channel_id> <binary_trace_file>
-e <trace file name>, --traceprettyprint reads in a vscsi cmd trace from the given
filename and sends a CSV formatted output to stdout; exclusive of all other options
vscsiStats Usage:
vscsiStats [options]
~ #
为使用此工具,需要首先使用"vscsiStats -l"命令列出主机上的虚拟机,显示信息中有虚拟机的worldGroupID和其虚拟磁盘vmdk的HandleID.
~ # vscsiStats -l
Virtual Machine worldGroupID: 5357184, Virtual Machine Display Name: Ubuntu1, Virtual Machine Config File: /vmfs/volumes/538de183-0b835da3-af75-782bcb608523/Ubuntu1/Ubuntu1.vmx, {
Virtual SCSI Disk handleID: 9329 (scsi0:0)
}
如果想收集某一虚拟机所有虚拟磁盘的性能数据,可以使用“vscsiStats -s worldGroupID"命令;如果仅想收集虚拟机某一虚拟磁盘的性能数据,可以使用”vscsiStats -s worldGroupID -i handleID“。vscsiStats收集30分钟的性能数据,你可以通过"vscsiStats -x"中断当前收集操作。使用下列命令可以查看性能具体历史统计图:
vscsistats -p ioLength
vscsistats -p seekDistance
vscsistats -p outstandingIOs
vscsistats -p latency
vscsistats -p interarrival
~ # vscsiStats -s -w 5357184 -i 9329
vscsiStats: Starting Vscsi stats collection for worldGroup 856812, handleID 8574 (scsi0:1)
Success.
~ # vscsiStats -p latency -w 5357184 -i 9329
Histogram: latency of IOs in Microseconds (us) for virtual machine worldGroupID : 5357184, virtual disk handleID : 9329 (scsi0:0) {
min : 99
max : 1933
mean : 947
count : 22
{
0 (<= 1)
0 (<= 10)
1 (<= 100)
11 (<= 500)
0 (<= 1000)
10 (<= 5000)
0 (<= 15000)
0 (<= 30000)
0 (<= 50000)
0 (<= 100000)
0 (> 100000)
}
}
......
vscsiStats收集的性能数据,是你通过esxtop或vCenter性能图标中无法获取的;配合esxtop和vCenter,可以帮助定位存储相关的性能问题。