Hyper-v 存储 i/o 性能Hyper-V Storage I/O Performance

本部分介绍在虚拟机中优化存储 i/o 性能的不同选项和注意事项。This section describes the different options and considerations for tuning storage I/O performance in a virtual machine. 存储 i/o 路径通过主机虚拟化层扩展到主机存储堆栈,然后再扩展到物理磁盘上。The storage I/O path extends from the guest storage stack, through the host virtualization layer, to the host storage stack, and then to the physical disk. 下面是有关如何在每个阶段进行优化的说明。Following are explanations about how optimizations are possible at each of these stages.

虚拟控制器Virtual controllers

Hyper-v 提供三种类型的虚拟控制器: IDE、SCSI 和虚拟主机总线适配器 (Hba) 。Hyper-V offers three types of virtual controllers: IDE, SCSI, and Virtual host bus adapters (HBAs).

IDEIDE

IDE 控制器将 IDE 磁盘公开给虚拟机。IDE controllers expose IDE disks to the virtual machine. IDE 控制器是模拟的,它是在没有虚拟机 Integration Services 的情况下可用于运行旧版 Windows 的来宾 Vm 的唯一控制器。The IDE controller is emulated, and it is the only controller that is available for guest VMs running older version of Windows without the Virtual Machine Integration Services. 使用与虚拟机 Integration Services 一起提供的 IDE 筛选器驱动程序执行的磁盘 i/o 明显优于与仿真 IDE 控制器一起提供的磁盘 i/o 性能。Disk I/O that is performed by using the IDE filter driver that is provided with the Virtual Machine Integration Services is significantly better than the disk I/O performance that is provided with the emulated IDE controller. 建议仅将 IDE 磁盘用于操作系统磁盘,因为它们具有性能限制,因为可以向这些设备颁发最大的 i/o 大小。We recommend that IDE disks be used only for the operating system disks because they have performance limitations due to the maximum I/O size that can be issued to these devices.

SCSI (SAS 控制器) SCSI (SAS controller)

SCSI 控制器将 SCSI 磁盘公开给虚拟机,每个虚拟 SCSI 控制器最多可支持64设备。SCSI controllers expose SCSI disks to the virtual machine, and each virtual SCSI controller can support up to 64 devices. 为了获得最佳性能,建议将多个磁盘附加到单个虚拟 SCSI 控制器并创建更多的控制器,因为这些控制器需要扩展连接到虚拟机的磁盘数。For optimal performance, we recommend that you attach multiple disks to a single virtual SCSI controller and create additional controllers only as they are required to scale the number of disks connected to the virtual machine. SCSI 路径不会模拟,这使得它成为操作系统磁盘以外的任何磁盘的首选控制器。SCSI path is not emulated which makes it the preferred controller for any disk other than the operating system disk. 实际上对于第2代 Vm,这是唯一可能的控制器类型。In fact with Generation 2 VMs, it is the only type of controller possible. 在 Windows Server 2012 R2 中引入,此控制器被报告为 SAS 以支持共享的 VHDX。Introduced in Windows Server 2012 R2, this controller is reported as SAS to support shared VHDX.

虚拟光纤通道 HbaVirtual Fibre Channel HBAs

虚拟光纤通道 Hba 可以配置为允许虚拟机的直接访问,以便通过以太网 (FCoE) Lun 来光纤通道和光纤通道。Virtual Fibre Channel HBAs can be configured to allow direct access for virtual machines to Fibre Channel and Fibre Channel over Ethernet (FCoE) LUNs. 虚拟光纤通道磁盘会绕过根分区中的 NTFS 文件系统,从而减少了存储 i/o 的 CPU 使用量。Virtual Fibre Channel disks bypass the NTFS file system in the root partition, which reduces the CPU usage of storage I/O.

对于来宾群集方案 (多个虚拟机之间共享的大型数据驱动器和驱动器) 是虚拟光纤通道磁盘的最佳候选项。Large data drives and drives that are shared between multiple virtual machines (for guest clustering scenarios) are prime candidates for virtual Fibre Channel disks.

虚拟光纤通道磁盘需要在主机上安装一个或多个光纤通道的主机总线适配器 (Hba) 。Virtual Fibre Channel disks require one or more Fibre Channel host bus adapters (HBAs) to be installed on the host. 每个主机 HBA 都需要使用支持 Windows Server 2016 Virtual 光纤通道/NPIV 功能的 HBA 驱动程序。Each host HBA is required to use an HBA driver that supports the Windows Server 2016 Virtual Fibre Channel/NPIV capabilities. SAN fabric 应支持 NPIV,用于虚拟光纤通道的 HBA 端口 (s) 应在支持 NPIV 的光纤通道拓扑中设置。The SAN fabric should support NPIV, and the HBA port(s) that are used for the virtual Fibre Channel should be set up in a Fibre Channel topology that supports NPIV.

为了最大限度地提高随多个 HBA 一起安装的主机的吞吐量,建议你在 Hyper-v 虚拟机内部配置多个虚拟 Hba, (可以为每个虚拟机) 配置最多4个 Hba。To maximize throughput on hosts that are installed with more than one HBA, we recommend that you configure multiple virtual HBAs inside the Hyper-V virtual machine (up to four HBAs can be configured for each virtual machine). Hyper-v 将自动尽力平衡虚拟 Hba,以托管访问同一虚拟 SAN 的 Hba。Hyper-V will automatically make a best effort to balance virtual HBAs to host HBAs that access the same virtual SAN.

虚拟磁盘Virtual disks

磁盘可以通过虚拟控制器公开给虚拟机。Disks can be exposed to the virtual machines through the virtual controllers. 这些磁盘可以是虚拟硬盘,是磁盘的文件抽象或主机上的传递磁盘。These disks could be virtual hard disks that are file abstractions of a disk or a pass-through disk on the host.

虚拟硬盘Virtual hard disks

有两个虚拟硬盘格式: VHD 和 VHDX。There are two virtual hard disk formats, VHD and VHDX. 其中每种格式都支持三种类型的虚拟硬盘文件。Each of these formats supports three types of virtual hard disk files.

VHD 格式VHD format

VHD 格式是过去版本中 Hyper-v 支持的唯一虚拟硬盘格式。The VHD format was the only virtual hard disk format that was supported by Hyper-V in past releases. Windows Server 2012 中引入了 VHD 格式,以允许更好地对齐,这使得新的大型扇区磁盘的性能明显更好。Introduced in Windows Server 2012, the VHD format has been modified to allow better alignment, which results in significantly better performance on new large sector disks.

在 Windows Server 2012 或更高版本上创建的任何新 VHD 都具有最佳的 4 KB 对齐方式。Any new VHD that is created on a Windows Server 2012 or newer has the optimal 4 KB alignment. 此对齐格式与以前的 Windows Server 操作系统完全兼容。This aligned format is completely compatible with previous Windows Server operating systems. 但是,对于来自不能识别大小为 4 KB 的分析器的新分配,对齐属性将中断,而不是从以前版本的 Windows Server 或非 Microsoft 分析程序) 的 VHD 分析器开始 (。However, the alignment property will be broken for new allocations from parsers that are not 4 KB alignment-aware (such as a VHD parser from a previous version of Windows Server or a non-Microsoft parser).

从以前的版本移动的任何 VHD 都不会自动转换为此改进后的 VHD 格式。Any VHD that is moved from a previous release does not automatically get converted to this new improved VHD format.

若要转换为新的 VHD 格式,请运行以下 Windows PowerShell 命令:To convert to new VHD format, run the following Windows PowerShell command:

Convert-VHD –Path E:\vms\testvhd\test.vhd –DestinationPath E:\vms\testvhd\test-converted.vhd

您可以检查系统上所有 Vhd 的 "对齐" 属性,并且应将其转换为最佳的 4 KB 对齐方式。You can check the alignment property for all the VHDs on the system, and it should be converted to the optimal 4 KB alignment. 使用原始 VHD 中的数据通过 " 从源创建 " 选项创建新的 vhd。You create a new VHD with the data from the original VHD by using the Create-from-Source option.

若要使用 Windows Powershell 检查对齐方式,请检查对齐线,如下所示:To check for alignment by using Windows Powershell, examine the Alignment line, as shown below:

Get-VHD –Path E:\vms\testvhd\test.vhd

Path                    : E:\vms\testvhd\test.vhd
VhdFormat               : VHD
VhdType                 : Dynamic
FileSize                : 69245440
Size                    : 10737418240
MinimumSize             : 10735321088
LogicalSectorSize       : 512
PhysicalSectorSize      : 512
BlockSize               : 2097152
ParentPath              :
FragmentationPercentage : 10
Alignment               : 0
Attached                : False
DiskNumber              :
IsDeleted               : False
Number                  :

若要使用 Windows PowerShell 验证对齐方式,请检查对齐线,如下所示:To verify alignment by using Windows PowerShell, examine the Alignment line, as shown below:

Get-VHD –Path E:\vms\testvhd\test-converted.vhd

Path                    : E:\vms\testvhd\test-converted.vhd
VhdFormat               : VHD
VhdType                 : Dynamic
FileSize                : 69369856
Size                    : 10737418240
MinimumSize             : 10735321088
LogicalSectorSize       : 512
PhysicalSectorSize      : 512
BlockSize               : 2097152
ParentPath              :
FragmentationPercentage : 0
Alignment               : 1
Attached                : False
DiskNumber              :
IsDeleted               : False
Number                  :

VHDX 格式VHDX format

VHDX 是 Windows Server 2012 中引入的一种新的虚拟硬盘格式,可用于创建高达 64 tb 的可恢复高性能虚拟磁盘。VHDX is a new virtual hard disk format introduced in Windows Server 2012, which allows you to create resilient high-performance virtual disks up to 64 terabytes. 此格式的优点包括:Benefits of this format include:

  • 支持的虚拟硬盘存储容量高达 64 tb。Support for virtual hard disk storage capacity of up to 64 terabytes.

  • 可通过记录对 VHDX 元数据结构的更新,保护数据在电源发生故障时不受损坏。Protection against data corruption during power failures by logging updates to the VHDX metadata structures.

  • 能够存储有关文件的自定义元数据,用户可能想要记录这些元数据,如操作系统版本或应用的修补程序。Ability to store custom metadata about a file, which a user might want to record, such as operating system version or patches applied.

VHDX 格式还提供以下性能优势:The VHDX format also provides the following performance benefits:

  • 改进了虚拟硬盘格式的对齐方式,以便能在大型扇区磁盘上更好地工作。Improved alignment of the virtual hard disk format to work well on large sector disks.

  • 动态磁盘和差异磁盘的块大小较大,这允许这些磁盘领域工作负荷的需求。Larger block sizes for dynamic and differential disks, which allows these disks to attune to the needs of the workload.

  • 4 KB 逻辑扇区虚拟磁盘,可在用于 4 KB 扇区的应用程序和工作负荷使用时提高性能。4 KB logical sector virtual disk that allows for increased performance when used by applications and workloads that are designed for 4 KB sectors.

  • 表示数据的效率,这会使文件大小变小,并允许基础物理存储设备回收未使用的空间。Efficiency in representing data, which results in smaller file size and allows the underlying physical storage device to reclaim unused space. (Trim 需要传递或 SCSI 磁盘和与剪裁兼容的硬件。 ) (Trim requires pass-through or SCSI disks and trim-compatible hardware.)

升级到 Windows Server 2016 时,建议你将所有 VHD 文件转换为 VHDX 格式,因为这些优势。When you upgrade to Windows Server 2016, we recommend that you convert all VHD files to the VHDX format due to these benefits. 只有在虚拟机可能会移到不支持 VHDX 格式的 Hyper-v 以前版本的情况下,才能将文件保留为 VHD 格式是唯一的情况。The only scenario where it would make sense to keep the files in the VHD format is when a virtual machine has the potential to be moved to a previous release of Hyper-V that does not support the VHDX format.

虚拟硬盘文件的类型Types of virtual hard disk files

有三种类型的 VHD 文件。There are three types of VHD files. 以下各节介绍了这些类型之间的性能特性和权衡。The following sections are the performance characteristics and trade-offs between the types.

在选择 VHD 文件类型时,应考虑以下建议:The following recommendations should be taken into consideration with regards to selecting a VHD file type:

  • 使用 VHD 格式时,建议使用固定类型,因为与其他 VHD 文件类型相比,它具有更好的复原能力和性能特征。When using the VHD format, we recommend that you use the fixed type because it has better resiliency and performance characteristics compared to the other VHD file types.

  • 当使用 VHDX 格式时,建议使用动态类型,因为它除了提供仅在需要时分配空间的空间节省,还提供复原保证。When using the VHDX format, we recommend that you use the dynamic type because it offers resiliency guarantees in addition to space savings that are associated with allocating space only when there is a need to do so.

  • 如果承载卷上的存储未处于主动监视状态,以确保在运行时扩展 VHD 文件时存在足够的磁盘空间,则也建议使用固定类型,而不考虑格式。The fixed type is also recommended, irrespective of the format, when the storage on the hosting volume is not actively monitored to ensure that sufficient disk space is present when expanding the VHD file at run time.

  • 虚拟机的快照创建用于存储写入磁盘的差异 VHD。Snapshots of a virtual machine create a differencing VHD to store writes to the disks. 只有几个快照可以提升存储 i/o 的 CPU 使用率,但可能不会明显影响性能,但在高 i/o 密集型服务器工作负荷中除外。Having only a few snapshots can elevate the CPU usage of storage I/Os, but might not noticeably affect performance except in highly I/O-intensive server workloads. 但是,由于从 VHD 中读取可能需要在多个差异 Vhd 中检查请求的块,因此具有大量快照可能会明显影响性能。However, having a large chain of snapshots can noticeably affect performance because reading from the VHD can require checking for the requested blocks in many differencing VHDs. 保持快照链的简短对于维护良好的磁盘 i/o 性能非常重要。Keeping snapshot chains short is important for maintaining good disk I/O performance.

固定虚拟硬盘类型Fixed virtual hard disk type

创建 VHD 文件时,将首先分配 VHD 的空间。Space for the VHD is first allocated when the VHD file is created. 这种类型的 VHD 文件不太可能分段,这减少了单个 i/o 被拆分为多个 i/o 时的 i/o 吞吐量。This type of VHD file is less likely to fragment, which reduces the I/O throughput when a single I/O is split into multiple I/Os. 由于读取和写入不需要查找块的映射,因此它具有三个 VHD 文件类型的最小 CPU 开销。It has the lowest CPU overhead of the three VHD file types because reads and writes do not need to look up the mapping of the block.

动态虚拟硬盘类型Dynamic virtual hard disk type

VHD 的空间按需分配。Space for the VHD is allocated on demand. 磁盘中的块作为未分配的块启动,不受文件中的任何实际空间支持。The blocks in the disk start as unallocated blocks and are not backed by any actual space in the file. 首次写入块时,虚拟化堆栈必须为块分配 VHD 文件中的空间,然后更新元数据。When a block is first written to, the virtualization stack must allocate space within the VHD file for the block, and then update the metadata. 这增加了写入所需的磁盘 i/o 数量并增加了 CPU 使用率。This increases the number of necessary disk I/Os for the Write and increases CPU usage. 在元数据中查找块映射时,读取和写入现有块会导致磁盘访问和 CPU 开销。Reads and writes to existing blocks incur disk access and CPU overhead when looking up the blocks' mapping in the metadata.

差异虚拟硬盘类型Differencing virtual hard disk type

VHD 指向父 VHD 文件。The VHD points to a parent VHD file. 不写入的任何块写入会导致 VHD 文件中的空间被分配,就像动态扩展的 VHD 一样。Any writes to blocks not written to result in space being allocated in the VHD file, as with a dynamically expanding VHD. 如果已将块写入,则从 VHD 文件处理读取。Reads are serviced from the VHD file if the block has been written to. 否则,将从父 VHD 文件中为其提供服务。Otherwise, they are serviced from the parent VHD file. 在这两种情况下,将读取元数据以确定块的映射。In both cases, the metadata is read to determine the mapping of the block. 此 VHD 的读取和写入会消耗更多 CPU,并导致比固定 VHD 文件更多的 i/o。Reads and Writes to this VHD can consume more CPU and result in more I/Os than a fixed VHD file.

块大小注意事项Block size considerations

块大小会显著影响性能。Block size can significantly impact performance. 最佳做法是将块大小与使用磁盘的工作负荷的分配模式相匹配。It is optimal to match the block size to the allocation patterns of the workload that is using the disk. 例如,如果应用程序在 16 MB 的块区中分配,则虚拟硬盘块大小为 16 MB 是最佳的。For example, if an application is allocating in chunks of 16 MB, it would be optimal to have a virtual hard disk block size of 16 MB. >只有 VHDX 格式的虚拟硬盘上才能有 2 MB 的块大小。A block size of >2 MB is possible only on virtual hard disks with the VHDX format. 对于随机 i/o 工作负荷的分配模式,更大的块大小会显著增加主机上的空间使用率。Having a larger block size than the allocation pattern for a random I/O workload will significantly increase the space usage on the host.

扇区大小影响Sector size implications

大多数软件行业都依赖于超过512个字节的磁盘扇区,但标准正在迁移到 4 KB 的磁盘扇区。Most of the software industry has depended on disk sectors of 512 bytes, but the standard is moving to 4 KB disk sectors. 为了降低512由于扇区大小的变化而导致的兼容性问题,硬盘驱动器供应商引入了) (512e 的转换大小。To reduce compatibility issues that might arise from a change in sector size, hard drive vendors are introducing a transitional size referred to as 512 emulation drives (512e).

这些模拟驱动器提供 4 KB 磁盘扇区本机驱动器提供的一些优点,例如改进的格式效率和改进的用于错误更正代码的方案 (ECC) 。These emulation drives offer some of the advantages that are offered by 4 KB disk sector native drives, such as improved format efficiency and an improved scheme for error correction codes (ECC). 它们产生的兼容性问题较少,因为它在磁盘接口上公开 4 KB 扇区大小。They come with fewer compatibility issues that would occur by exposing a 4 KB sector size at the disk interface.

支持512e 磁盘Support for 512e disks

512e 磁盘只能以物理扇区的形式执行写入,也就是说,它不能直接写入颁发给它的512byte 扇区。A 512e disk can perform a write only in terms of a physical sector—that is, it cannot directly write a 512byte sector that is issued to it. 磁盘中可执行这些写入的内部过程可遵循以下步骤:The internal process in the disk that makes these writes possible follows these steps:

  • 磁盘会将 4 KB 物理扇区读取到其内部缓存中,其中包含写入中提到的512字节逻辑扇区。The disk reads the 4 KB physical sector to its internal cache, which contains the 512-byte logical sector referred to in the write.

  • 将 4 KB 缓冲区中的数据修改为包含更新的 512 个字节扇区。Data in the 4 KB buffer is modified to include the updated 512-byte sector.

  • 磁盘将已更新的 4 KB 缓冲区写回到其磁盘上的物理扇区。The disk performs a write of the updated 4 KB buffer back to its physical sector on the disk.

此过程称为读修改-写入 (RMW) 。This process is called read-modify-write (RMW). RMW 进程对总体性能的影响取决于工作负荷。The overall performance impact of the RMW process depends on the workloads. 由于以下原因,RMW 进程会导致虚拟硬盘性能下降:The RMW process causes performance degradation in virtual hard disks for the following reasons:

  • 动态和差异虚拟硬盘在其数据负载之前具有512字节扇区的位图。Dynamic and differencing virtual hard disks have a 512-byte sector bitmap in front of their data payload. 此外,页脚、页眉和父定位符将与512字节扇区对齐。In addition, footer, header, and parent locators align to a 512-byte sector. 虚拟硬盘驱动程序通常会发出512字节写入命令以更新这些结构,从而导致前面所述的 RMW 过程。It is common for the virtual hard disk driver to issue 512-byte write commands to update these structures, resulting in the RMW process described earlier.

  • 应用程序通常以 4 KB 大小的倍数发出读取和写入 (NTFS) 的默认群集大小。Applications commonly issue reads and writes in multiples of 4 KB sizes (the default cluster size of NTFS). 由于动态和差异虚拟硬盘的数据负载块前面有一个512字节扇区的位图,所以 4 KB 块与物理 4 KB 边界不对齐。Because there is a 512-byte sector bitmap in front of the data payload block of dynamic and differencing virtual hard disks, the 4 KB blocks are not aligned to the physical 4 KB boundary. 下图显示了一个 VHD 4 KB 块 (突出显示的) 与物理 4 KB 边界不对齐。The following figure shows a VHD 4 KB block (highlighted) that is not aligned with physical 4 KB boundary.

vhd 4 kb 块

由当前分析器发出的用于更新有效负载数据的每个 4 KB 写入命令都将对磁盘上的两个块执行两次读取,然后将更新这些块并随后写回到这两个磁盘块。Each 4 KB write command that is issued by the current parser to update the payload data results in two reads for two blocks on the disk, which are then updated and subsequently written back to the two disk blocks. Windows Server 2016 中的 hyper-v 通过准备前面提到的结构来对齐 VHD 格式的 4 KB 边界,降低了 VHD 堆栈上的512e 磁盘的某些性能影响。Hyper-V in Windows Server 2016 mitigates some of the performance effects on 512e disks on the VHD stack by preparing the previously mentioned structures for alignment to 4 KB boundaries in the VHD format. 这可以避免在访问虚拟硬盘文件中的数据以及更新虚拟硬盘元数据结构时 RMW 的效果。This avoids the RMW effect when accessing the data within the virtual hard disk file and when updating the virtual hard disk metadata structures.

如前文所述,从以前版本的 Windows Server 复制的 Vhd 不会自动对齐到 4 KB。As mentioned earlier, VHDs that are copied from previous versions of Windows Server will not automatically be aligned to 4 KB. 可以使用 VHD 接口中提供的 "从源磁盘 复制 " 选项,手动将其转换为最佳对齐方式。You can manually convert them to optimally align by using the Copy from Source disk option that is available in the VHD interfaces.

默认情况下,Vhd 的物理扇区大小为512字节。By default, VHDs are exposed with a physical sector size of 512 bytes. 这样做是为了确保在应用程序和 Vhd 从以前版本的 Windows Server 移动时不影响物理扇区大小的从属应用程序。This is done to ensure that physical sector size dependent applications are not impacted when the application and VHDs are moved from a previous version of Windows Server.

默认情况下,将使用 4 KB 物理扇区大小创建带有 VHDX 格式的磁盘,以优化其性能配置文件常规磁盘和大型扇区磁盘。By default, disks with the VHDX format are created with the 4 KB physical sector size to optimize their performance profile regular disks and large sector disks. 若要充分利用 4 KB 扇区,建议使用 VHDX 格式。To make full use of 4 KB sectors it's recommended to use VHDX format.

支持本机 4 KB 磁盘Support for native 4 KB disks

Windows Server 2012 R2 和更高版本中的 hyper-v 支持 4 KB 本机磁盘。Hyper-V in Windows Server 2012 R2 and beyond supports 4 KB native disks. 但仍可以在 4 KB 本机磁盘上存储 VHD 磁盘。But it is still possible to store VHD disk on 4 KB native disk. 这是通过在虚拟存储堆栈层实现软件 RMW 算法实现的,该方法将512字节访问和更新请求转换为相应的 4 KB 访问和更新。This is done by implementing a software RMW algorithm in the virtual storage stack layer that converts 512-byte access and update requests to corresponding 4 KB accesses and updates.

由于 VHD 文件只能将自身作为512字节逻辑扇区大小的磁盘公开,因此很有可能会出现发出512字节 i/o 请求的应用程序。Because VHD file can only expose themselves as 512-byte logical sector size disks, it is very likely that there will be applications that issue 512-byte I/O requests. 在这些情况下,RMW 层将满足这些请求并导致性能下降。In these cases, the RMW layer will satisfy these requests and cause performance degradation. 对于带有逻辑扇区大小为512字节的 VHDX 格式的磁盘也是如此。This is also true for a disk that is formatted with VHDX that has a logical sector size of 512 bytes.

可以配置一个 VHDX 文件,使其作为 4 KB 逻辑扇区大小的磁盘公开,这在将磁盘托管到 4 KB 本机物理设备上时,这将是最佳的性能配置。It is possible to configure a VHDX file to be exposed as a 4 KB logical sector size disk, and this would be an optimal configuration for performance when the disk is hosted on a 4 KB native physical device. 应小心谨慎,以确保使用虚拟磁盘的来宾和应用程序支持 4 KB 逻辑扇区大小。Care should be taken to ensure that the guest and the application that is using the virtual disk are backed by the 4 KB logical sector size. VHDX 格式将在 4 KB 逻辑扇区大小设备上正常工作。The VHDX formatting will work correctly on a 4 KB logical sector size device.

传递磁盘Pass-through disks

虚拟机中的 VHD 可以直接映射到 (LUN) 的物理磁盘或逻辑单元号,而不是映射到 VHD 文件。The VHD in a virtual machine can be mapped directly to a physical disk or logical unit number (LUN), instead of to a VHD file. 优点是此配置会绕过根分区中的 NTFS 文件系统,从而减少存储 i/o 的 CPU 使用量。The benefit is that this configuration bypasses the NTFS file system in the root partition, which reduces the CPU usage of storage I/O. 风险是,物理磁盘或 Lun 在不同于 VHD 文件的计算机之间移动可能更困难。The risk is that physical disks or LUNs can be more difficult to move between machines than VHD files.

应避免使用传递磁盘,因为虚拟机迁移方案中引入了限制。Pass-through disks should be avoided due to the limitations introduced with virtual machine migration scenarios.

高级存储功能Advanced storage features

服务存储质量 (QoS)Storage Quality of Service (QoS)

从 Windows Server 2012 R2 开始,Hyper-v 包括为虚拟机上的存储设置某些服务质量 (QoS) 参数。Starting in Windows Server 2012 R2, Hyper-V includes the ability to set certain quality-of-service (QoS) parameters for storage on the virtual machines. 存储 QoS 在多租户环境中提供了存储性能隔离,以及在存储 I/O 性能不满足定义的阈值时通知你的机制,以便高效运行你的虚拟机工作负载。Storage QoS provides storage performance isolation in a multitenant environment and mechanisms to notify you when the storage I/O performance does not meet the defined threshold to efficiently run your virtual machine workloads.

存储 QoS 能够为你的虚拟硬盘指定每秒输入/输出操作次数 (IOPS) 的最大值。Storage QoS provides the ability to specify a maximum input/output operations per second (IOPS) value for your virtual hard disk. 管理员可以限制存储 I/O,以防止某个租户占用过多的存储资源,这可能影响其他租户。An administrator can throttle the storage I/O to stop a tenant from consuming excessive storage resources that may impact another tenant.

还可以设置最小 IOPS 值。You can also set a minimum IOPS value. 当指定虚拟硬盘的 IOPS 小于其最佳性能所需的阈值时,他们将收到通知。They will be notified when the IOPS to a specified virtual hard disk is below a threshold that is needed for its optimal performance.

还使用与存储相关的参数更新虚拟机指标基础结构,以允许管理员监视性能和与退款相关的参数。The virtual machine metrics infrastructure is also updated, with storage related parameters to allow the administrator to monitor the performance and chargeback related parameters.

最大值和最小值以规范化 IOPS 为依据,其中每 8 KB 的数据计为一个 i/o。Maximum and minimum values are specified in terms of normalized IOPS where every 8 KB of data is counted as an I/O.

其中一些限制如下:Some of the limitations are as follows:

  • 仅适用于虚拟磁盘Only for virtual disks

  • 差异磁盘在不同的卷上不能有父虚拟磁盘Differencing disk cannot have parent virtual disk on a different volume

  • 副本-与主站点分开配置的副本站点的 QoSReplica - QoS for replica site configured separately from primary site

  • 不支持共享 VHDXShared VHDX is not supported

有关存储服务质量的详细信息,请参阅 hyper-v 的存储服务质量For more info on Storage Quality of Service, see Storage Quality of Service for Hyper-V.

NUMA I/ONUMA I/O

Windows Server 2012 和更高版本支持大型虚拟机和任何大型虚拟机配置 (例如,具有64虚拟) 处理器 Microsoft SQL Server 运行的配置在 i/o 吞吐量方面也需要可伸缩性。Windows Server 2012 and beyond supports large virtual machines, and any large virtual machine configuration (for example, a configuration with Microsoft SQL Server running with 64 virtual processors) will also need scalability in terms of I/O throughput.

以下重要改进首次在 Windows Server 2012 存储堆栈和 Hyper-v 中引入,提供了大型虚拟机的 i/o 可伸缩性需求:The following key improvements first introduced in the Windows Server 2012 storage stack and Hyper-V provide the I/O scalability needs of large virtual machines:

  • 在来宾设备与主机存储堆栈之间增加的通信通道数的增加。An increase in the number of communication channels created between the guest devices and host storage stack.

  • 一种更有效的 i/o 完成机制,涉及虚拟处理器间的中断分布,以避免昂贵的 interprocessor 中断。A more efficient I/O completion mechanism involving interrupt distribution amongst the virtual processors to avoid expensive interprocessor interruptions.

Windows Server 2012 中引入了几个注册表项,它们位于 HKLM \ 系统 \ CurrentControlSet \ Enum \ VMBUS \ {device id} \ {instance id} \ StorChannel,这允许调整通道数。Introduced in Windows Server 2012, there are a few registry entries, located at HKLM\System\CurrentControlSet\Enum\VMBUS\{device id}\{instance id}\StorChannel, that allow the number of channels to be adjusted. 它们还将处理 i/o 完成的虚拟处理器与应用程序分配给 i/o 处理器的虚拟 Cpu 对齐。They also align the virtual processors that handle the I/O completions to the virtual CPUs that are assigned by the application to be the I/O processors. 注册表设置在设备硬件密钥上基于每个适配器进行配置。The registry settings are configured on a per-adapter basis on the device's hardware key.

  • **ChannelCount (DWORD) ** 要使用的通道总数,最大值为16。ChannelCount (DWORD) The total number of channels to use, with a maximum of 16. 它的默认值为上限,即虚拟处理器/16 的数目。It defaults to a ceiling, which is the number of virtual processors/16.

  • **ChannelMask (QWORD) ** 通道的处理器关联。ChannelMask (QWORD) The processor affinity for the channels. 如果未设置或设置为0,则默认为用于普通存储或网络通道的现有通道分发算法。If it is not set or is set to 0, it defaults to the existing channel distribution algorithm that you use for normal storage or for networking channels. 这可确保存储通道不会与网络通道发生冲突。This ensures that your storage channels won't conflict with your network channels.

卸载数据传输集成Offloaded Data Transfer integration

Vhd 的重要维护任务(如合并、移动和压缩)都依赖于复制大量数据。Crucial maintenance tasks for VHDs, such as merge, move, and compact, depend copying large amounts of data. 当前复制数据的方法需要在其他位置进行读写操作,这是一个非常耗时的过程。The current method of copying data requires data to be read in and written to different locations, which can be a time-consuming process. 它还使用主机上的 CPU 和内存资源,这些资源可能已用于为虚拟机服务。It also uses CPU and memory resources on the host, which could have been used to service virtual machines.

存储区域网络 (SAN) 供应商正致力于提供几乎能瞬间复制大量数据的功能。Storage area network (SAN) vendors are working to provide near-instantaneous copy operations of large amounts of data. 此存储设计用于允许磁盘上的系统将特定数据集从一个位置移动到另一个位置。This storage is designed to allow the system above the disks to specify the move of a specific data set from one location to another. 此硬件功能称为卸载数据传输。This hardware feature is known as an Offloaded Data Transfer.

Windows Server 2012 和更高版本中的 hyper-v 支持卸载数据传输 (ODX) 操作,以便这些操作可以从来宾操作系统传递到主机硬件。Hyper-V in Windows Server 2012 and beyond supports Offload Data Transfer (ODX) operations so that these operations can be passed from the guest operating system to the host hardware. 这可确保工作负荷可以使用启用 ODX 的存储,就像它在非虚拟化环境中运行一样。This ensures that the workload can use ODX-enabled storage as it would if it were running in a non-virtualized environment. Hyper-v 存储堆栈还会在维护操作期间为 Vhd (如合并磁盘和存储迁移元操作,其中移动了大量数据)发出 ODX 操作。The Hyper-V storage stack also issues ODX operations during maintenance operations for VHDs such as merging disks and storage migration meta-operations where large amounts of data are moved.

取消映射集成Unmap integration

虚拟硬盘文件作为文件存在于存储卷上,它们与其他文件共享可用空间。Virtual hard disk files exist as files on a storage volume, and they share available space with other files. 由于这些文件的大小往往很大,它们占用的空间可能会迅速增长。Because the size of these files tends to be large, the space that they consume can grow quickly. 对更多物理存储的需求会影响 IT 硬件预算。Demand for more physical storage affects the IT hardware budget. 尽可能优化物理存储的使用非常重要。It's important to optimize the use of physical storage as much as possible.

在 Windows Server 2012 之前,当应用程序删除虚拟硬盘中的内容(此操作实际上放弃了内容的存储空间)时,来宾操作系统中的 Windows 存储堆栈和 Hyper-v 主机会阻止将此信息传递给虚拟硬盘和物理存储设备。Before Windows Server 2012, when applications delete content within a virtual hard disk, which effectively abandoned the content's storage space, the Windows storage stack in the guest operating system and the Hyper-V host had limitations that prevented this information from being communicated to the virtual hard disk and the physical storage device. 这会阻止 Hyper-v 存储堆栈通过基于 VHD 的虚拟磁盘文件优化空间使用量。This prevented the Hyper-V storage stack from optimizing the space usage by the VHD-based virtual disk files. 它还会阻止基础存储设备回收已删除数据以前占用的空间。It also prevented the underlying storage device from reclaiming the space that was previously occupied by the deleted data.

从 Windows Server 2012 开始,Hyper-v 支持取消映射通知,这使得 VHDX 文件在表示其中的数据时更有效。Starting from Windows Server 2012, Hyper-V supports unmap notifications, which allow VHDX files to be more efficient in representing that data within it. 这会生成较小的文件,并允许基础物理存储设备回收未使用的空间。This results in smaller files size, and it allows the underlying physical storage device to reclaim unused space.

只有特定于 Hyper-v 的 SCSI、启用 IDE 和虚拟光纤通道控制器允许来宾的取消映射命令访问主机虚拟存储堆栈。Only Hyper-V-specific SCSI, enlightened IDE, and Virtual Fibre Channel controllers allow the unmap command from the guest to reach the host virtual storage stack. 在虚拟硬盘上,只有设置为 VHDX 格式的虚拟磁盘才支持来宾的取消映射命令。On the virtual hard disks, only virtual disks formatted as VHDX support unmap commands from the guest.

出于此原因,我们建议在不使用虚拟光纤通道磁盘时,使用附加到 SCSI 控制器的 VHDX 文件。For these reasons, we recommend that you use VHDX files attached to a SCSI controller when not using Virtual Fibre Channel disks.

其他参考Additional References