使用 Azure Stack Hub 连接到 iSCSI 存储Connect to iSCSI storage with Azure Stack Hub

可以使用本文中的模板,将 Azure Stack Hub 虚拟机 (VM) 连接到本地 iSCSI 目标,并将 VM 设置为使用托管在 Azure Stack Hub 外部和数据中心其他位置的存储。You can use the template in this article to connect an Azure Stack Hub virtual machine (VM) to an on-premises iSCSI target set up the VM to use storage hosted outside of our Azure Stack Hub and elsewhere in your datacenter. 本文介绍如何将 Windows 计算机用作 iSCSI 目标。This article looks at using a Windows machine as the iSCSI target.

可以在 Azure 智能边缘模式 GitHub 存储库的 lucidqdreams 分支中找到该模板。You can find the template in the lucidqdreams fork of Azure Intelligent Edge Patterns GitHub repository. 该模板位于 storage-iSCSI 文件夹中。The template is in the storage-iSCSI folder. 该模板旨在用于设置 Azure Stack Hub 端所需的基础结构,以便连接到 iSCSI 目标。The template has been designed to set up up the infrastructure necessary on the Azure Stack Hub side to connect to an iSCSI target. 此配置包括用作 iSCSI 发起程序的虚拟机,及其随附的 VNet、NSG、PIP 和存储。This includes a virtual machine that will act as the iSCSI Initiator along with its accompanying VNet, NSG, PIP, and storage. 部署该模板之后,需要运行两个 PowerShell 脚本来完成配置。After the template has been deployed, two PowerShell scripts need to be, run to complete the configuration. 其中一个脚本在本地 VM(目标)上运行,另一个在 Azure Stack Hub VM(发起端)上运行。One script will be run on the on-premises VM (target) and one will be run on the Azure Stack Hub VM (Initiator). 这些操作完成后,本地存储即会添加到 Azure Stack Hub VM。Once these are completed, you will have on-premises storage added to your Azure Stack Hub VM.

概述Overview

下图显示了托管在 Azure Stack Hub 上的 VM,其中包含从本地 Windows 计算机(物理或虚拟机)装载的 iSCSI 磁盘,它允许通过 iSCSI 协议将 Azure Stack Hub 外部的存储装载到 Azure Stack Hub 托管的 VM 内部。The diagram shows a VM hosted on Azure Stack Hub with an iSCSI mounted disk from a Windows machine on premises (physical or virtual) allowing storage external to Azure Stack Hub to mount inside your Azure Stack Hub hosted VM over the iSCSI protocol.

替换文字

要求Requirements

  • 运行 Windows Server 2016 Datacenter 或 Windows Server 2019 Datacenter 的本地计算机(物理或虚拟机)。An on-premises machine (physical or virtual) running Windows Server 2016 Datacenter or Windows Server 2019 Datacenter.
  • 所需的 Azure Stack Hub 市场项:Required Azure Stack Hub Marketplace items:
    • Windows Server 2016 Datacenter 或 Windows Server 2019 Datacenter(建议使用最新内部版本)。Windows Server 2016 Datacenter or Windows Server 2019 Datacenter (latest build recommended).
    • PowerShell DSC 扩展。PowerShell DSC extension.
    • 自定义脚本扩展。Custom Script Extension.
    • 现有的虚拟机或物理机。An existing virtual or physical machine. 此计算机最好是配备了两个网络适配器。Ideally this machine will have two network adapters. 它也可以是另一个 iSCSI 目标,例如实例的 SAN。This could also be another iSCSI target such as a SAN for instance.

注意事项Things to consider

  • 某个网络安全组将应用到模板子网。A Network Security Group is applied to the template Subnet. 请注意到这一点,并根据需要另行预留额度。Review this and make additional allowances as needed.
  • RDP“拒绝”规则将应用到隧道 NSG,如果你倾向于通过公共 IP 地址访问 VM,则需要将此规则设置为“允许”。An RDP Deny rule is applied to the Tunnel NSG and will need to be set to allow if you intend to access the VMs via the Public IP address.
  • 此解决方案不考虑 DNS 解析。This solution does not take into account DNS resolution.
  • 请更改 Chapusername 和 Chappassword。You should change your Chapusername and Chappassword. Chappassword 的长度必须是 12 到 16 个字符。The Chappassword must be 12 to 16 characters in length.
  • 此模板对 VM 使用静态 IP 地址,因为 iSCSI 连接使用配置中的本地地址。This template is using a static IP address for the VM as the iSCSI connection uses the local address in the configuration.
  • 此模板使用 BYOL Windows 许可证。This template is using BYOL Windows License.
  • 还可以将基于 Linux 的系统连接到 iSCSI 目标。You can also connect Linux-based systems to the iSCSI targets. 可以在 Ubuntu 文档的 iSCSI 发起程序一文中找到相关说明。You can find instructions in the iSCSI Initiator article in the ubuntu documentation.

选项Options

  • 可以通过 _artifactsLocation_artifactsLocationSasToken 参数使用自己的 Blob 存储帐户和 SAS 令牌,这样就能配合 SAS 令牌使用自己的存储 Blob。You can use your own Blob storage account and SAS token using the _artifactsLocation and _artifactsLocationSasToken parameters the ability to use your own storage blob with SAS token.
  • 此模板为 VNet 命名和 IP 寻址提供默认值。This template provides default values for VNet naming and IP addressing.
  • 此配置只包含一个来自 iSCSI 客户端的 iSCSI NIC。This configuration only has one iSCSI nic coming from the iSCSI client. 我们已测试过多种配置,以利用不同的子网和 NIC,但是,测试期间多个网关出现了问题,因此我们正在尝试创建单独的存储子网来隔离流量(真正冗余的配置)。We had tested a number of configurations to utilize separate subnets and NICs however ran into issues with multiple gateways and trying to create a separate storage subnet to isolate traffic and actually be truly redundant.
  • 请谨慎地使这些值保持在合法的子网和地址范围内,否则部署可能失败。Be careful to keep these values within legal subnet and address ranges as deployment may fail.
  • PowerShell DSC 包的主要用途是检查是否存在挂起的重新启动。The PowerShell DSC packages primary purpose is to check for pending reboots. 如果需要,可以进一步自定义此 DSC。This DSC can be customized further, if needed. 有关详细信息,请参阅 omputerManagementDscFor more information see omputerManagementDsc.

资源组模板(iSCSI 客户端)Resource group template (iSCSI client)

下图显示了通过模板部署的资源,这些资源用于创建可供连接到 iSCSI 目标的 iSCSI 客户端。The diagram shows the resources deployed from the template to create the iSCSI client you can use to connect to the iSCSI target. 此模板将部署 VM 和其他资源,此外,它还运行 prepare-iSCSIClient.ps1 并重新启动 VM。This template will deploy the VM and other resources, In addition, it will run the prepare-iSCSIClient.ps1 and reboot the VM.

替换文字

部署过程The Deployment process

资源组模板生成输出作为下一步骤的输入。The resource group template generates output, which is meant to be the input for the next step. 它着重于发出 iSCSI 流量的服务器名称和 Azure Stack Hub 公共 IP 地址。It is mainly focused on the server name and the Azure Stack Hub public IP address where the iSCSI traffic originates. 对于本示例:For this example:

  1. 部署基础结构模板。Deploy the infrastructure template.
  2. 将 Azure Stack Hub VM 部署到托管在数据中心其他位置的 VM。Deploy an Azure Stack Hub VM to a VM hosted elsewhere in your datacenter.
  3. 使用模板输出的 IP 地址和服务器名称作为 iSCSI 目标(可以是虚拟机或物理服务器)上脚本的输入输出参数,来运行 Create-iSCSITarget.ps1Run Create-iSCSITarget.ps1 using the IP address and server name outputs from the template as in-out parameters for the script on the iSCSI target, which can be a virtual machine or physical server.
  4. 使用 iSCSI 目标服务器的外部 IP 地址作为输入来运行 Connect-toiSCSITarget.ps1 脚本。Use the external IP address or addresses of the iSCSI Target server as inputs to run the Connect-toiSCSITarget.ps1 script.

替换文字

azuredeploy.json 的输入Inputs for azuredeploy.json

参数Parameters default default descriptiondescription
WindowsImageSKUWindowsImageSKU 2019-Datacenter2019-Datacenter 请选择 Windows VM 基础映像Please select the base Windows VM image
VMSizeVMSize Standard_D2_v2Standard_D2_v2 请输入 VM 大小Please enter the VM size
VMNameVMName FileServerFileServer VM 名称VM name
adminUsernameadminUsername storageadminstorageadmin 新 VM 的管理员名称The name of the Administrator of the new VM
adminPasswordadminPassword 新 VM 管理员帐户的密码。The password for the Administrator account of the new VMs. 默认值为订阅 IDDefault value is subscription ID
VNetNameVNetName 存储Storage VNet 的名称。The name of VNet. 用于标记资源This will be used to label the resources
VNetAddressSpaceVNetAddressSpace 10.10.0.0/2310.10.0.0/23 VNet 的地址空间Address Space for VNet
VNetInternalSubnetNameVNetInternalSubnetName 内部Internal VNet 内部子网名称VNet Internal Subnet Name
VNetInternalSubnetRangeVNetInternalSubnetRange 10.10.1.0/2410.10.1.0/24 VNet 内部子网的地址范围Address Range for VNet Internal Subnet
InternalVNetIPInternalVNetIP 10.10.1.410.10.1.4 文件服务器内部 IP 的静态地址。Static Address for the internal IP of the File Server.
_artifactsLocation_artifactsLocation
_artifactsLocationSasToken_artifactsLocationSasToken

部署步骤Deployment steps

  1. 使用 azuredeploy.json 部署 iSCSI 客户端基础结构Deploy iSCSI client Infrastructure using azuredeploy.json
  2. 在本地服务器 iSCSI 目标上运行 Create-iSCSITarget.ps1Run Create-iSCSITarget.ps1 on the on-premises server iSCSI target. 模板完成之后,需在本地服务器 iSCSI 目标上使用第一个步骤的输出来运行 Create-iSCSITarget.ps1Once the template completes, you will need to run the Create-iSCSITarget.ps1 on the on-premises server iSCSI target with the outputs from the first step
  3. 在 iSCSI 客户端上运行 Connect-toiSCSITarget.ps1Run Connect-toiSCSITarget.ps1 on the on iSCSI client. 使用 iSCSI 目标的详细信息在 iSCSI 客户端上运行 Connect-toiSCSITarget.ps1un the Connect-toiSCSITarget.ps1 on the on iSCSI client with the details of the iSCSI target

将 iSCSI 存储添加到现有 VMAdding iSCSI storage to existing VMs

也可以在现有虚拟机上运行脚本,以从 iSCSI 客户端连接到 iSCSI 目标。You can also run the scripts on an existing Virtual Machine to connect from the iSCSI client to a iSCSI target. 下面是自行创建 iSCSI 目标的流程。This flow is if you are creating the iSCSI target yourself. 下图显示 PowerShell 脚本的执行流。This diagram shows the execution flow of the PowerShell scripts. 这些脚本可在 Script 目录中找到:These scripts can be found in the Script directory:

替换文字

Prepare-iSCSIClient.ps1Prepare-iSCSIClient.ps1

Prepare-iSCSIClient.ps1 脚本在 iSCSI 客户端上安装必备组件,包括:The Prepare-iSCSIClient.ps1 script installs the prerequisites on the iSCSI client, this includes;

  • 安装多路径 IO 服务installation of Multipath-IO services
  • 将 iSCSI 发起程序服务设置为自动启动setting the iSCSI initiator service start up to automatic
  • 启用对 iSCSI 多路径 MPIO 的支持enabling support for multipath MPIO to iSCSI
  • 启用所有 iSCSI 卷的自动声明Enable automatic claiming of all iSCSI volumes
  • 将磁盘超时设置为 60 秒Set the disk timeout to 60 seconds

安装这些必备组件后,必须重新启动系统。It is important to reboot the system after installation of these prerequisites. MPIO 负载均衡策略需要重新启动才能进行设置。The MPIO load-balancing policy requires a reboot so that it can be set.

Create-iSCSITarget.ps1Create-iSCSITarget.ps1

Create-iSCSITarget.ps1 脚本将在提供存储的系统上运行。The Create-iSCSITarget.ps1 script is to be run on the system, which is serving the storage. 可以创建受到发起端限制的多个磁盘和目标。You can create multiple disks and targets restricted by initiators. 可运行此脚本多次,以创建多个可附加到不同目标的虚拟磁盘。You can run this script multiple times to create many virtual disks you can attach to different targets. 可将多个磁盘连接到一个目标。You can connect multi-disks to one target.

输入Input default default descriptiondescription
RemoteServerRemoteServer FileServerFileServer 连接到 iSCSI 目标的服务器的名称The name of the server connecting to the iSCSI Target
RemoteServerIPsRemoteServerIPs 1.1.1.11.1.1.1 iSCSI 流量的来源 IP 地址The IP Address the iSCSI traffic will be coming from
DiskFolderDiskFolder C:\iSCSIVirtualDisksC:\iSCSIVirtualDisks 存储虚拟磁盘的文件夹和驱动器The folder and drive where the virtual disks will be stored
DiskNameDiskName DiskNameDiskName 磁盘 VHDX 文件的名称The name of the disk VHDX file
DiskSizeDiskSize 5GB5GB VHDX 磁盘大小The VHDX disk size
TargetNameTargetName RemoteTarget01RemoteTarget01 用于定义 iSCSI 客户端目标配置的目标名称。The target name used to define the target configuration for the iSCSI client.
ChapUsernameChapUsername usernameusername 用于 Chap 身份验证的用户名The username name for Chap authentication
ChapPasswordChapPassword userP@ssw0rd!userP@ssw0rd! 用于 Chap 身份验证的密码名称。The password name for Chap authentication. 长度必须为 12 到 16 个字符It must be 12 to 16 characters

Connect-toiSCSITarget.ps1Connect-toiSCSITarget.ps1

Connect-toiSCSITarget.ps1 是最后一个脚本,它在 iSCSI 客户端上运行,将 iSCSI 目标提供的磁盘装载到 iSCSI 客户端。The Connect-toiSCSITarget.ps1 is the final script, which is run on the iSCSI client and mounts the disk presented by the iSCSI target to the iSCSI client.

输入Input default default descriptiondescription
TargetiSCSIAddressesTargetiSCSIAddresses "2.2.2.2","2.2.2.3""2.2.2.2","2.2.2.3" iSCSI 目标的 IP 地址The IP addresses of the iSCSI target
LocalIPAddressesLocalIPAddresses "10.10.1.4""10.10.1.4" 这是 iSCSI 流量的来源内部 IP 地址This is internal IP Address the iSCSI traffic will be coming from
LoadBalancePolicyLoadBalancePolicy C:\iSCSIVirtualDisksC:\iSCSIVirtualDisks iSCSI 流量的来源 IP 地址The IP Address the iSCSI traffic will be coming from
ChapUsernameChapUsername usernameusername 用于 Chap 身份验证的用户名The username name for Chap authentication
ChapPasswordChapPassword userP@ssw0rd!userP@ssw0rd! 用于 Chap 身份验证的密码名称。The password name for Chap authentication. 长度必须为 12 到 16 个字符It must be 12 to 16 characters

后续步骤Next steps

Azure Stack Hub 网络的差异和注意事项Differences and considerations for Azure Stack Hub networking