共享 Azure 托管磁盘Share an Azure managed disk

Azure 共享磁盘是 Azure 托管磁盘的一项新功能,可同时将托管磁盘附加到多个虚拟机 (VM)。Azure shared disks is a new feature for Azure managed disks that allows 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.

工作原理How it works

群集中的 VM 可根据群集应用程序使用 SCSI 永久预留 (SCSI PR) 选择的预留来读取或写入附加的磁盘。VMs in the cluster can read or write to their attached disk based on the reservation chosen by the clustered application using SCSI Persistent Reservations (SCSI PR). SCSI PR 是一种行业标准,可供本地存储区域网络 (SAN) 上运行的应用程序利用。SCSI PR is an industry standard leveraged by applications running on Storage Area Network (SAN) on-premises. 在托管磁盘上启用 SCSI PR,可以将这些应用程序按原样迁移到 Azure。Enabling SCSI PR on a managed disk allows you to migrate these applications to Azure as-is.

共享托管磁盘提供了可从多个 VM 进行访问的共享块存储,这些存储作为逻辑单元号 (LUN) 公开。Shared managed disks offer shared block storage that can be accessed from multiple VMs, these are exposed as logical unit numbers (LUNs). 然后,会将 LUN 从目标(磁盘)提供给发起程序 (VM)。LUNs are then presented to an initiator (VM) from a target (disk). 这些 LUN 看起来像直接附加存储 (DAS) 或 VM 的本地驱动器。These LUNs look like direct-attached-storage (DAS) or a local drive to the VM.

共享托管磁盘本身并不提供可以使用 SMB/NFS 访问的完全托管的文件系统。Shared managed disks do not natively offer a fully managed file system that can be accessed using SMB/NFS. 需要使用群集管理器(如 Windows Server 故障转移群集 (WSFC) 或 Pacemaker)来处理群集节点通信和写入锁定。You need to use a cluster manager, like Windows Server Failover Cluster (WSFC) or Pacemaker, that handles cluster node communication and write locking.

限制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 with maxShares>1.
  • 磁盘突发不适用于采用 maxShares>1 的高级 SSD。Disk bursting is not available for premium SSDs with maxShares>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.

操作系统要求Operating system requirements

共享磁盘支持多个操作系统。Shared disks support several operating systems. 有关支持的操作系统,请参阅 WindowsLinux 部分。See the Windows or Linux sections 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=2For 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.

示例工作负载Sample workloads

WindowsWindows

Windows Server 2008 及更高版本支持 Azure 共享磁盘。Azure shared disks are supported on Windows Server 2008 and newer. 大多数基于 Windows 的群集构建于 WSFC 上,它处理群集节点通信的所有核心基础结构,使应用程序能够利用并行访问模式。Most Windows-based clustering builds on WSFC, which handles all core infrastructure for cluster node communication, allowing your applications to take advantage of parallel access patterns. WSFC 根据 Windows Server 的版本启用 CSV 和非 CSV 的选项。WSFC enables both CSV and non-CSV-based options depending on your version of Windows Server. 有关详细信息,请参阅创建故障转移群集For details, refer to Create a failover cluster.

WSFC 上运行的热门应用程序包括:Some popular applications running on WSFC include:

LinuxLinux

支持 Azure 共享磁盘的项如下所示:Azure shared disks are supported on:

Linux 群集可以利用群集管理器,例如 PacemakerLinux clusters can leverage cluster managers such as Pacemaker. Pacemaker 基于 Corosync 构建,可为部署在高可用环境中的应用程序启用群集通信。Pacemaker builds on Corosync, enabling cluster communications for applications deployed in highly available environments. 一些常见的群集文件系统包括 ocfs2gfs2Some common clustered filesystems include ocfs2 and gfs2. 可使用基于 SCSI 永久预留 (SCSI PR) 和/或 STONITH 块设备 (SBD) 的群集模型对磁盘进行仲裁访问。You can use SCSI Persistent Reservation (SCSI PR) and/or STONITH Block Device (SBD) based clustering models for arbitrating access to the disk. 使用 SCSI PR 时,可使用 fence_scsisg_persist 之类的实用程序来处理预留和注册。When using SCSI PR, you can manipulate reservations and registrations using utilities such as fence_scsi and sg_persist.

永久预留流Persistent reservation flow

下图演示了一个示例 2 节点群集数据库应用程序,该应用程序利用 SCSI PR 启用从一个节点到另一个节点的故障转移。The following diagram illustrates a sample 2-node clustered database application that leverages SCSI PR to enable failover from one node to the other.

双节点群集。群集上运行的应用程序正在处理对磁盘的访问

工作流如下所述:The flow is as follows:

  1. 在 Azure VM1 和 VM2 上运行的群集应用程序均注册了其读取或写入磁盘的意图。The clustered application running on both Azure VM1 and VM2 registers its intent to read or write to the disk.
  2. 然后,VM1 上的应用程序实例将使用独占预留以写入磁盘。The application instance on VM1 then takes exclusive reservation to write to the disk.
  3. 已在 Azure 磁盘上强制执行此预留,并且数据库现在可以独占方式写入磁盘。This reservation is enforced on your Azure disk and the database can now exclusively write to the disk. 从 VM2 上的应用程序实例进行的任何写入都不会成功。Any writes from the application instance on VM2 will not succeed.
  4. 如果 VM1 上的应用程序实例关闭,则 VM2 上的实例现在可以启动数据库故障转移和磁盘接管。If the application instance on VM1 goes down, the instance on VM2 can now initiate a database failover and take-over of the disk.
  5. 现在,已在 Azure 磁盘上强制执行此预留,并且该磁盘将不再接受来自 VM1 的写入。This reservation is now enforced on the Azure disk and the disk will no longer accept writes from VM1. 它将只接受来自 VM2 的写入。It will only accept writes from VM2.
  6. 群集应用程序可以完成数据库故障转移并处理来自 VM2 的请求。The clustered application can complete the database failover and serve requests from VM2.

下图说明了另一个常见的群集工作负载,该工作负载由多个节点组成,这些节点从磁盘读取数据以运行并行进程,例如机器学习模型训练。The following diagram illustrates another common clustered workload consisting of multiple nodes reading data from the disk for running parallel processes, such as training of machine learning models.

四节点 VM 群集,每个节点注册写入意图,应用程序进行独占预留以正确处理写入结果

工作流如下所述:The flow is as follows:

  1. 所有 VM 上运行的群集应用程序均注册了其读取或写入磁盘的意图。The clustered application running on all VMs registers the intent to read or write to the disk.
  2. 然后,VM1 上的应用程序实例将使用独占预留以写入磁盘,同时开放其他 VM 的磁盘读取。The application instance on VM1 takes an exclusive reservation to write to the disk while opening up reads to the disk from other VMs.
  3. 将在 Azure 磁盘上强制执行此预留。This reservation is enforced on your Azure disk.
  4. 群集中的所有节点现在都可以从磁盘中读取。All nodes in the cluster can now read from the disk. 只有一个节点代表群集中的所有节点将结果写回磁盘。Only one node writes back results to the disk, on behalf of all nodes in the cluster.

性能限制Performance throttles

高级 SSD 性能限制Premium SSD performance throttles

使用高级 SSD 时,磁盘 IOPS 和吞吐量是固定的;例如,P30 的 IOPS 是 5000。With premium SSD, the disk IOPS and throughput is fixed, for example, IOPS of a P30 is 5000. 无论磁盘是跨 2 个 VM 还是 5 个 VM 进行共享,都保留此值。This value remains whether the disk is shared across 2 VMs or 5 VMs. 可从单个 VM 达到磁盘限额,也可跨两个或多个 VM 分配这些限额。The disk limits can be reached from a single VM or divided across two or more VMs.

后续步骤Next steps

如果你有兴趣为托管磁盘启用和使用共享磁盘,请参阅我们的文章:启用共享磁盘If you're interested in enabling and using shared disks for your managed disks, proceed to our article Enable shared disk