为 Azure Stack HCI 创建存储路径

适用于:Azure Stack HCI 版本 23H2

本文介绍如何为 Azure Stack HCI 群集上使用的 VM 映像创建存储路径。 存储路径是 Azure 资源,用于提供在群集上存储 VM 配置文件、VM 映像和 VHD 的路径。 可以使用 Azure CLI 创建存储路径。

关于存储路径

部署 Azure Stack HCI 群集时,会在部署过程中创建存储路径。 默认选项会自动选择具有高可用性的存储路径。 但是,你可能决定使用特定的存储路径。 在这种情况下,请确保指定的存储路径具有足够的存储空间。

Azure Stack HCI 群集上的存储路径应指向群集上所有服务器都可以访问的群集共享卷。 为了高度可用,强烈建议在群集共享卷下创建存储路径。

群集共享卷中的可用空间决定了存储路径中可用存储的大小。 例如,如果存储路径为 C:\ClusterStorage\UserStorage_1\Volume01 ,而 Volume01 为 4 TB,则存储路径的大小 (上 Volume014 TB) 中的可用空间。

先决条件

在开始之前,请确保满足以下先决条件:

  1. 确保有权访问已部署和注册的 Azure Stack HCI 群集。 在部署期间,还会创建 Arc 资源网桥和自定义位置。

    转到 Azure 中的资源组。 可以看到为 Azure Stack HCI 群集创建的自定义位置和 Azure Arc 资源网桥。 请记下订阅、资源组和自定义位置,稍后你会在本方案中使用这些信息。

  2. 请确保 Azure Stack HCI 群集上存在可从群集中的所有服务器访问的群集共享卷。 要在群集共享卷上提供的存储路径应有足够的空间来存储 VM 映像。 默认情况下,群集共享卷是在部署 Azure Stack HCI 群集期间创建的。

    只能在群集中可用的群集共享卷中创建存储路径。 有关详细信息,请参阅 创建群集共享卷

在群集上创建存储路径

可以使用 Azure CLI 或 Azure 门户在群集上创建存储路径。

可以使用 stack-hci-vm storagepath cmdlet 在 Azure Stack HCI 群集上创建、显示和列出存储路径。

查看用于创建存储路径的参数

创建存储路径时 需要 以下参数:

参数 说明
name 为 Azure Stack HCI 群集创建的存储路径的名称。 请确保提供符合 Azure 资源规则的名称。 创建存储路径后,无法对其进行重命名。
resource-group 在其中创建存储路径的资源组的名称。 为便于管理,建议使用与 Azure Stack HCI 群集相同的资源组。
subscription 部署 Azure Stack HCI 的订阅的名称或 ID。 这也可能是用于 Azure Stack HCI 群集上的存储路径的另一个订阅。
custom-location 与要在其中创建此存储路径的 Azure Stack HCI 群集关联的自定义位置的名称或 ID。
路径 磁盘上用于创建存储路径的路径。 所选路径应有足够的空间来存储 VM 映像。

还可以使用以下 可选 参数:

参数 说明
location az locations 指定的 Azure 区域。

创建存储路径

在 Azure Stack HCI 群集的其中一台服务器上按照以下步骤创建存储路径:

登录并设置订阅

  1. 连接到 Azure Stack HCI 系统上的服务器。

  2. 登录。 键入:

    az login --use-device-code
    
  3. 设置订阅。

    az account set --subscription <Subscription ID>
    

设置参数

  1. 为映像的订阅、资源组、位置和 OS 类型设置参数。 < >将 替换为相应的值。

    $storagepathname="<Storage path name>"
    $path="<Path on the disk to cluster shared volume>"
    $subscription="<Subscription ID>"
    $resource_group="<Resource group name>"
    $customLocName="<Custom location of your Azure Stack HCI cluster>"
    $customLocationID="/subscriptions/<Subscription ID>/resourceGroups/$reource_group/providers/Microsoft.ExtendedLocation/customLocations/$customLocName"
    $location="<Azure region where the cluster is deployed>"
    
  2. 在以下路径 test-storagepath 处创建存储路径: C:\ClusterStorage\test-storagepath。 运行以下 cmdlet:

    az stack-hci-vm storagepath create --resource-group $resource_group --custom-location $customLocationID --name $storagepathname --path $path
    

    有关此 cmdlet 的详细信息,请参阅 az stack-hci-vm storagepath create

    下面是示例输出:

    PS C:\windows\system32> $storagepathname="test-storagepath"
    PS C:\windows\system32> $path="C:\ClusterStorage\UserStorage_1\mypath"
    PS C:\windows\system32> $subscription="<Subscription ID>"
    PS C:\windows\system32> $resource_group="myhci-rg"
    PS C:\windows\system32> $customLocationID="/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.ExtendedLocation/customLocations/myhci-cl"
    
    PS C:\windows\system32> az stack-hci-vm storagepath create --name $storagepathname --resource-group $resource_group --custom-location $customLocationID --path $path
    Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
    {
      "extendedLocation": {
        "name": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.ExtendedLocation/customLocations/myhci-cl",
        "type": "CustomLocation"
      },
      "id": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/storagecontainers/test-storagepath",
      "location": "eastus",
      "name": "test-storagepath",
      "properties": {
        "path": "C:\\ClusterStorage\\UserStorage_1\\mypath",
        "provisioningState": "Succeeded",
        "status": {
          "availableSizeMB": 36761,
          "containerSizeMB": 243097
        }
      },
      "resourceGroup": "myhci-rg",
      "systemData": {
        "createdAt": "2023-10-06T04:45:30.458242+00:00",
        "createdBy": "guspinto@contoso.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-10-06T04:45:57.386895+00:00",
        "lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
        "lastModifiedByType": "Application"
      },
      "tags": null,
      "type": "microsoft.azurestackhci/storagecontainers"
    }
    

存储路径创建完成后,即可创建虚拟机映像。

删除存储路径

如果存储路径不是必需的,可以将其删除。 若要删除存储路径,请先删除关联的工作负载,然后运行以下命令以删除存储路径:

az stack-hci-vm storagepath delete --resource-group "<resource group name>" --name "<storagepath name>" --yes

若要验证是否已删除存储路径,请运行以下命令:

az stack-hci-vm storagepath show --resource-group "<resource group name>" --name "<storagepath name>" 

你会收到存储路径不存在的通知。

若要删除卷,请先删除关联的工作负载,然后删除存储路径,然后删除卷。 有关详细信息,请参阅 删除卷

如果存储路径上没有足够的空间,则使用该存储路径的 VM 预配将失败。 可能需要展开与存储路径关联的卷。 有关详细信息,请参阅 展开卷

后续步骤