启用共享磁盘Enable shared disk
本文介绍了如何为 Azure 托管磁盘启用共享磁盘功能。This article covers how to enable the shared disks feature for Azure managed disks. Azure 共享磁盘是 Azure 托管磁盘的一项新功能,可同时将托管磁盘附加到多个虚拟机 (VM)。Azure shared disks is a new feature for Azure managed disks that enables you to attach a managed disk to multiple virtual machines (VMs) simultaneously. 通过将托管磁盘附加到多个 VM,可以向 Azure 部署新的群集应用程序或迁移现有的群集应用程序。Attaching a managed disk to multiple VMs allows you to either deploy new or migrate existing clustered applications to Azure.
如果你正在查找有关已启用共享磁盘的托管磁盘的概念信息,请参阅 Azure 共享磁盘。If you are looking for conceptual information on managed disks that have shared disks enabled, see Azure shared disks.
限制Limitations
仅可对部分磁盘类型启用共享磁盘。Enabling shared disks is only available to a subset of disk types. 目前只有高级 SSD 可启用共享磁盘。Currently only premium SSDs can enable shared disks. 已启用共享磁盘的托管磁盘受到下列限制,这些限制按磁盘类型进行整理:The managed disk that have shared disks enabled are subject to the following limitations, organized by disk type:
高级 SSDPremium SSDs
- 当前仅限于 Azure 资源管理器或 SDK 支持。Currently limited to Azure Resource Manager or SDK support.
- 仅可对数据磁盘启用,不可对 OS 磁盘启用。Can only be enabled on data disks, not OS disks.
- ReadOnly 主机缓存不适用于采用
maxShares>1
的高级 SSD。ReadOnly host caching is not available for premium SSDs withmaxShares>1
. - 磁盘突发不适用于采用
maxShares>1
的高级 SSD。Disk bursting is not available for premium SSDs withmaxShares>1
. - 通过 Azure 共享磁盘将可用性集与虚拟机规模集一起使用时,不会对共享数据磁盘强制实施与虚拟机容错域的存储容错域对齐。When using Availability sets and virtual machine scale sets with Azure shared disks, storage fault domain alignment with virtual machine fault domain is not enforced for the shared data disk.
- 使用 邻近放置组 (PPG) 时,共享一个磁盘的所有虚拟机都必须属于同一个 PPG。When using proximity placement groups (PPG), all virtual machines sharing a disk must be part of the same PPG.
- 只可对 Windows Server 故障转移群集的某些版本使用基本磁盘;有关详细信息,请参阅故障转移群集硬盘要求和存储选项。Only basic disks can be used with some versions of Windows Server Failover Cluster, for details see Failover clustering hardware requirements and storage options.
- Azure 备份和 Azure Site Recovery 支持尚不可用。Azure Backup and Azure Site Recovery support is not yet available.
区域可用性Regional availability
可在提供托管磁盘的所有区域中使用共享高级 SSD。Shared premium SSDs are available in all regions that managed disks are available.
支持的操作系统Supported operating systems
共享磁盘支持多个操作系统。Shared disks support several operating systems. 有关支持的操作系统,请参阅概念文章的 Windows 和 Linux 部分。See the Windows and Linux sections of the conceptual article for the supported operating systems.
磁盘大小Disk sizes
目前,只有高级 SSD 可启用共享磁盘。For now, only premium SSDs can enable shared disks. 如果磁盘大小不同,则 maxShares
限制可能也不同,设置 maxShares
值时不可超过此限制。Different disk sizes may have a different maxShares
limit, which you cannot exceed when setting the maxShares
value. 对于高级 SSD,支持共享磁盘的磁盘大小至少是 P15。For premium SSDs, the disk sizes that support sharing their disks are P15 and greater.
对于每个磁盘,可定义一个 maxShares
值来表示可同时共享磁盘的最大节点数。For each disk, you can define a maxShares
value that represents the maximum number of nodes that can simultaneously share the disk. 例如,如果计划设置一个双节点故障转移群集,可设置 maxShares=2
。For example, if you plan to set up a 2-node failover cluster, you would set maxShares=2
. 上限就是最大值。The maximum value is an upper bound. 只要节点数低于指定的 maxShares
值,节点就可加入或离开群集(装载或卸载磁盘)。Nodes can join or leave the cluster (mount or unmount the disk) as long as the number of nodes is lower than the specified maxShares
value.
备注
仅在磁盘从所有节点中拆离后,还可设置或编辑 maxShares
值。The maxShares
value can only be set or edited when the disk is detached from all nodes.
高级·SSD 范围Premium SSD ranges
下表说明了按高级磁盘大小得出的 maxShares
的最大允许值:The following table illustrates the allowed maximum values for maxShares
by premium disk sizes:
磁盘大小Disk sizes | maxShares 限制maxShares limit |
---|---|
P15、P20P15, P20 | 22 |
P30、P40、P50P30, P40, P50 | 55 |
P60、P70、P80P60, P70, P80 | 1010 |
磁盘的 IOPS 和带宽限制不受 maxShares
值影响。The IOPS and bandwidth limits for a disk are not affected by the maxShares
value. 例如,无论 maxShares = 1 还是 maxShares > 1,P15 磁盘的 IOPS 上限都为 1100。For example, the max IOPS of a P15 disk is 1100 whether maxShares = 1 or maxShares > 1.
部署共享磁盘Deploy shared disks
将高级 SSD 部署为共享磁盘Deploy a premium SSD as a shared disk
若要部署启用了共享磁盘功能的托管磁盘,请使用新属性 maxShares
并定义大于 1 的值。To deploy a managed disk with the shared disk feature enabled, use the new property maxShares
and define a value greater than 1. 这会使该磁盘可在多个 VM 之间共享。This makes the disk shareable across multiple VMs.
重要
仅当从所有 VM 中卸载了某个磁盘时,才能设置或更改 maxShares
的值。The value of maxShares
can only be set or changed when a disk is unmounted from all VMs. 有关 maxShares
的允许值,请参阅磁盘大小。See the Disk sizes for the allowed values for maxShares
.
az disk create -g myResourceGroup -n mySharedDisk --size-gb 1024 -l chinaeast --sku Premium_LRS --max-shares 2
将 Azure 共享磁盘与 VM 配合使用Using Azure shared disks with your VMs
使用 maxShares>1
部署共享磁盘后,可以将该磁盘装载到一个或多个 VM。Once you've deployed a shared disk with maxShares>1
, you can mount the disk to one or more of your VMs.
$resourceGroup = "myResourceGroup"
$location = "chinanorth"
$vm = New-AzVm -ResourceGroupName $resourceGroup -Name "myVM" -Location $location -VirtualNetworkName "myVnet" -SubnetName "mySubnet" -SecurityGroupName "myNetworkSecurityGroup" -PublicIpAddressName "myPublicIpAddress"
$dataDisk = Get-AzDisk -ResourceGroupName $resourceGroup -DiskName "mySharedDisk"
$vm = Add-AzVMDataDisk -VM $vm -Name "mySharedDisk" -CreateOption Attach -ManagedDiskId $dataDisk.Id -Lun 0
update-AzVm -VM $vm -ResourceGroupName $resourceGroup
支持的 SCSI PR 命令Supported SCSI PR commands
将共享磁盘装载到群集中的 VM 后,可以使用 SCSI PR 建立仲裁以及在磁盘中进行读取/写入操作。Once you've mounted the shared disk to your VMs in your cluster, you can establish quorum and read/write to the disk using SCSI PR. 使用 Azure 共享磁盘时,可以使用以下 PR 命令:The following PR commands are available when using Azure shared disks:
若要与磁盘进行交互,请从 persistent-reservation-action 列表开始:To interact with the disk, start with the persistent-reservation-action list:
PR_REGISTER_KEY
PR_REGISTER_AND_IGNORE
PR_GET_CONFIGURATION
PR_RESERVE
PR_PREEMPT_RESERVATION
PR_CLEAR_RESERVATION
PR_RELEASE_RESERVATION
使用 PR_RESERVE、PR_PREEMPT_RESERVATION 或 PR_RELEASE_RESERVATION 时,请提供下列 persistent-reservation-type 之一:When using PR_RESERVE, PR_PREEMPT_RESERVATION, or PR_RELEASE_RESERVATION, provide one of the following persistent-reservation-type:
PR_NONE
PR_WRITE_EXCLUSIVE
PR_EXCLUSIVE_ACCESS
PR_WRITE_EXCLUSIVE_REGISTRANTS_ONLY
PR_EXCLUSIVE_ACCESS_REGISTRANTS_ONLY
PR_WRITE_EXCLUSIVE_ALL_REGISTRANTS
PR_EXCLUSIVE_ACCESS_ALL_REGISTRANTS
使用 PR_RESERVE、PR_REGISTER_AND_IGNORE、PR_REGISTER_KEY、PR_PREEMPT_RESERVATION、PR_CLEAR_RESERVATION 或 PR_RELEASE-RESERVATION 时,还需要提供 persistent-reservation-key。You also need to provide a persistent-reservation-key when using PR_RESERVE, PR_REGISTER_AND_IGNORE, PR_REGISTER_KEY, PR_PREEMPT_RESERVATION, PR_CLEAR_RESERVATION, or PR_RELEASE-RESERVATION.
后续步骤Next steps
如果希望使用 Azure 资源管理器模板来部署磁盘,可使用以下示例模板:If you prefer to use Azure Resource Manager templates to deploy your disk, the following sample templates are available: