Configuring Windows iSCSI Initiator with PowerShell: A Connect to iSCSITarget
2 iSCSI Initiator
iSCSI Initiator(iSCSI 启动器)
- Microsoft®Internet iSCSI Initiator(iSCSI 启动器)是 iSCSI 的客户端,与SCSI总线适配器一起工作。可以通过以太网网络适配器将运行 Windows®Family 或 Windows Server®Family 的主机连接到基于 iSCSI 的外部存储阵列。
要通过IP网络传输iSCSI命令块,必须在iSCSI主机上安装iSCSI驱动程序。Microsoft iSCSI Initiator 附带了一个iSCSI驱动程序。用过使用 1/10G 网络适配器 (每秒传输1000/10000 Mbps) 来连接 iSCSITarget 存储。
3 iSCSI Initiator(iSCSI 启动器)分类:
iSCSI Initiator(iSCSI 启动器)启动分为,软件类和硬件类:
- 软件类 iSCSI Initiator:通过代码实现 iSCSI。该驱动程序使用现有的网卡(NIC)和网络堆栈,通过使用iSCSI协议模拟计算机的SCSI设备。
- 硬件类 iSCSI Initiator:使用专用的硬件。(通常与在该硬件上运行的固件相结合)来实现iSCSI。硬件启动器可以减轻 iSCSI和TCP 处理以及以太网中断的开销,可以提高使用iSCSI的服务器的性能。iSCSI主机总线适配器(更常见的是HBA)实现硬件启动器。
-
HBA被打包为 1/10G 以太网接口控制器、某种TCP/IP卸载引擎(TOE)技术和一个SCSI总线适配器的组合。
- iSCSI HBA 可以包含PCI选项ROM,以允许从iSCSI SAN引导。
- iSCSI offload engine(iSCSI卸载引擎)或iSOE card(iSOE卡)提供了一个完整 iSCSI HBA 代替方案。从主机处理器“卸载”特定网络接口的iSCSI启动器操作,为主机应用程序释放CPU资源。
- iSCSI HBAs 或 iSOEs 用于性能增强。iSOE 可以通过附加的服务来实现,比如TCP offload engine (TOE),从而进一步减少主机服务器CPU的使用。
4 Microsoft iSCSI Initiator 功能\组件
Microsoft iSCSI Initiator 通过连接到IP网络并发起请求并从iSCSI目标接收响应的服务器。Microsoft iSCSI Initiator 中的SAN功能组件很大程度上类似于光纤通道SAN功能组件,它们包括以下内容:
4.1 功能
- Microsoft iSCSI Initiator 附带了对以下功能的支持:
功能名称 | None | |
---|---|---|
iSCSI Naming Service (iSNS) | iSCSI命名服务 | 在大型环境中提供易于管理和受控发现的功能 |
iSCSI/Remote Boot | iSCSI 远程启动 | 支持从运行Windows Server 2008 R2的计算机上的在线存储进行远程启动。 |
CHAP | 单双向验证 | 允许单向和双向CHAP对Microsoft iSCSI Initiator和目标进行身份验证 |
Digests | 摘要 | 使用Intel Slicing-by-8算法为软件标头和数据摘要计算提供高级支持 |
Support for IPV6 addressing | 支持IPV6寻址 | 除IPv4外,还使用IPv6地址和协议 |
IPsec | IPset | 通过加密数据帮助确保隐私。 |
Multipath I/O (MPIO) | 微软多路径 I/O 处理 | 通过利用执行应用程序的CPU与物理存储数据的iSCSI目标之间的多条路径,帮助确保数据的高可用性 |
4.2 组件
- Microsoft iSCSI Initiator 中的SAN组件包括以下内容:
组件名称 | None | |
---|---|---|
Kernel-mode driver (mini port driver—msiscsi.sys) |
内核模式驱动程序 | SCSI设备驱动程序组件,负责将数据从存储堆栈移动到网络堆栈。这种驱动程序仅在iSCSI流量使用标准网络适配器时运行,而非使用专用iSCSI HBA运行。此驱动程序和一些多功能HBA支持Storport存储驱动程序。 |
Initiator service (iscsiexe.dll) |
启动程序服务 | 为系统管理所有Microsoft iSCSI启动程序(包括网络适配器和HBA)服务。其功能包括聚合设备发现信息和管理安全性。Internet存储名称服务(iSNS)客户端包括发现和连接到运行Microsoft iSCSI Initiator的服务器的支持。 |
Management applications | 管理程序 | 程序包括 iSCSI command-line interface命令行界面(iSCSICLI.exe),graphical user interface 图形用户界面(iscsicpl.exe)属性页和 Windows Management Instrumentation(WMI) |
Multipath I/O support for iSCSI (including device-specific module drivers) |
多路径,包括特定于设备的模块驱动程序 | 指定用于设备的模块(DSM)驱动程序,为外部存储阵列提供高可用性路径故障转移和负载平衡。 |
iSCSI Target | iSCSI 目标 | iSCSITarget 接收来自 iSCSI 命令的任何设备。设备可以是终端节点,例如存储设备、中间设备,例如IP和光纤通道、存储阵列控制器网桥上的每个端口由一个或多个IP地址标识。 |
5 Discovery mechanisms(发现机制)
Microsoft iSCSI Initiator 支持四种发现机制:
- SendTargets(发送目标)
Microsoft iSCSI Initiator 执行iSCSI发现登录,然后对使用 iscsicli AddTargetPortal 命令配置静态的门户和门户组,然后执行SendTargets操作。 - Internet Storage Name Service(iSNS)(Internet存储名称服务)
Microsoft iSCSI Initiator 使用 iSNS 服务器的地址是通过 iscsicli AddiSNSServer 命令静态配置的。 - HBA discovery(HBA发现)
iSCSI HBA 可以通过 HBA 和 Microsoft iSCSI Initiator 服务之间的接口参与目标发现。每当服务启动时以及HBA提示目标列表已更改时,Microsoft iSCSI Initiator 都会从HBA请求目标列表。 - Manually configured targets(手动配置目标)
使用 iscsicli AddTarget 命令或 Microsoft iSCSI Initiator 中的图形用户界面手动配置iSCSI目标。可以将手动配置的目标配置为“隐藏”,在这种情况下,除非另一个机制发现目标,否则不会报告目标。
手动配置的目标会保留。只要服务重新启动,那些未配置为隐藏的目标仍然可用。
!注意
每个 iSCSI 主机都由唯一的iSCSI限定名称(IQN)标识,该名称类似于光纤通道全球名称(WWN)。同时Microsoft不支持在Windows操作系统上使用非Microsoft iSCSI软件启动程序。
Microsoft 已经通过 Designed for Windows 徽标计划认证,支持使用的iSCSI HBA,不支持不使用Microsoft iSCSI Initiator服务的iSCSI HBA。
6 实例:A Connect to iSCSI
6.1 Configuring an iSCSI target connection for a Windows failover cluster
6.1.1
Configuring nodes and other node server configurations : Configuring an iSCSItarget connection for a Windows failover cluster (为 Windows 故障转移群集配置 iSCSI 目标连接)
1 2 3 4 5 6 7 8 9 10 11 12 13 |
# 启用 Windows 更新服务 Get-Service -Name "wuauserv", "Windows Update", "TrustedInstaller", "msiserver" | Start-Service # 启用 Multipath-IO (启用 Windows 系统内置的 多路径 I/O 功能) Enable-WindowsOptionalFeature -Online -FeatureName MultipathIo Set-Service -Name MSiSCSI -StartupType Automatic Get-Service -Name MSiSCSI | Sort-Object {$_.Start()} # 启动节点上的 iSCSI 客户端服务 Enable-MSDSMAutomaticClaim -BusType iSCSI # 启用对 iSCSI 设备的多路径支持 #Enable-MSDSMAutomaticClaim -BusType SAS # 启用对 SAS 设备的多路径支持 |
6.1.2
Configuring nodes and other node server configurations : Configuring an iSCSItarget connection (配置 iSCSI 目标连接)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 定义 ############################################################################################################################# $iSCSI_AC_01 = "172.168.186.71" # 定义:iSCSI 存储控制器的IP地址 $iSCSI_BC_01 = "172.168.186.72" $iSCSI_AC_02 = "172.168.186.73" $iSCSI_BC_02 = "172.168.186.74" ############################################################################################################################## # 变量=获取 interface 别名具有 iSCSI 的网卡的 IPv4地址 作为变量值 # iSCSI Adapter Number Port Number $iSCSIAdapter1P1 = (Get-NetIPAddress -InterfaceAlias "iSCSI_1_P1").IPv4Address $iSCSIAdapter1P2 = Get-NetIPAddress -InterfaceAlias "iSCSI_1_P2" | ForEach {$_.IPv4Address} $iSCSIAdapter2P1 = (Get-NetIPAddress -InterfaceAlias "iSCSI_2_P1").IPv4Address $iSCSIAdapter2P2 = Get-NetIPAddress -InterfaceAlias "iSCSI_2_P2" | ForEach {$_.IPv4Address} New-IscsiTargetPortal -InitiatorPortalAddress $iSCSIAdapter1P1 -TargetPortalAddress $iSCSI_AC_01 -TargetPortalPortNumber 3260 New-IscsiTargetPortal -InitiatorPortalAddress $iSCSIAdapter1P2 -TargetPortalAddress $iSCSI_BC_02 -TargetPortalPortNumber 3260 New-IscsiTargetPortal -InitiatorPortalAddress $iSCSIAdapter2P1 -TargetPortalAddress $iSCSI_BC_01 -TargetPortalPortNumber 3260 New-IscsiTargetPortal -InitiatorPortalAddress $iSCSIAdapter2P2 -TargetPortalAddress $iSCSI_AC_02 -TargetPortalPortNumber 3260 ping Unknown > Null # 获取所有的iSCSI目标 | 连接iSCSI目标 本地地址为$iSLIP1 A/B iSCSI服务器节点A的地址为$iSCSI1/2_Node1/2_AddrA/B 启用多路径 重启后自动连接 Get-IscsiTarget | Connect-IscsiTarget -InitiatorPortalAddress $iSCSIAdapter1P1 -TargetPortalAddress $iSCSI_AC_01 -IsMultipathEnabled $true -IsPersistent $true Get-IscsiTarget | Connect-IscsiTarget -InitiatorPortalAddress $iSCSIAdapter1P2 -TargetPortalAddress $iSCSI_BC_02 -IsMultipathEnabled $true -IsPersistent $true Get-IscsiTarget | Connect-IscsiTarget -InitiatorPortalAddress $iSCSIAdapter2P1 -TargetPortalAddress $iSCSI_BC_01 -IsMultipathEnabled $true -IsPersistent $true Get-IscsiTarget | Connect-IscsiTarget -InitiatorPortalAddress $iSCSIAdapter2P2 -TargetPortalAddress $iSCSI_AC_02 -IsMultipathEnabled $true -IsPersistent $true ping Unknown > Null |
6.2 Configuring an iSCSI target virtual disk (配置 iSCSI 目标 虚拟磁盘)
6.2.1
Configuring nodes and other node server configurations : Configuring an iSCSItarget connection (挂载 iSCSI 虚拟磁盘)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# 获取所有磁盘为只读的磁盘,将其设置为 假 Get-Disk | Where-Object {$_.IsReadOnly -match $true} | Set-Disk -IsReadOnly $false ping Unknown > Null # 获取所有为离线的磁盘,将其设置为 假 Get-Disk | Where-Object {$_.IsOffline -match $true} | Set-Disk -IsOffline $false ping Unknown > Null # 获取所有磁盘分区类型为 RAW 的磁盘,也就是未初始化的磁盘,然后递归,并将磁盘初始化为 GPT 分区类型 Get-Disk | Where-Object {$_.PartitionStyle -eq "RAW"} | Initialize-Disk -PartitionStyle GPT ping Unknown > Null # 该更改 Powershell 的默认默认确认级别,改变为 None 以便关闭确认窗口 $ConfirmPreference='None' |
6.2.2
Configuring nodes and other node server configurations : Initialize the production iSCSItarget virtual disk for the configuration node (初始化配置节点的生产 Iscsi 目标虚拟磁盘)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# 定义 ############################################################################################################################# $Oge = "99GB" # 定义 OnlineDisk(生产磁盘)>99GB 空间的磁盘 $Ole = "100GB" # 定义 OnlineDisk(生产磁盘)≤100GB 空间的磁盘 $Qge = "9GB" # 定义 QDisk(见证磁盘)>9GB 空间的磁盘 $Qle = "10GB" # 定义 QDisk(见证磁盘)≤10GB 空间的磁盘 ############################################################################################################################## #### 配置 主配置节点 生产磁盘 # 获取磁盘空间 # | 递归然后新建分区,分区空间为最大化使用,自动分配驱动器编号 # | 递归 格式化卷,指定文件系统为 NTFS,然后分配指定的卷标 Q_Disk #### Configure and Manage the Production of the disk 配置 Cluster 的生产磁盘 (ONLine) Get-Disk | Where-Object {($_.Size -ge $Oge) -and ($_.Size -le $Ole)} | New-Partition -UseMaximumSize -DriveLetter "O" | Get-Partition | Format-Volume -FileSystem NTFS -NewFileSystemLabel "ONline" -Force |
6.2.3
Configuring nodes configurations : Initialize the quorum, witness, share iSCSItarget virtual disk in the cluster (初始化群集中的 “仲裁、见证、共享” iSCSI 目标虚拟磁盘)
1 2 3 4 5 6 7 8 |
#### 配置 配置节点和余下节点间的 Q Disk 仲裁磁盘 # 获取磁盘空间 # | 递归:新建分区 分区空间最大化 指定分区编号为 Q; # | 递归:获取分区 # | 递归:格式化卷 指定文件系统为 NTFS 新建卷标名称为 Q Disk Get-Disk | Where-Object {($_.Size -ge $Qge) -and ($_.Size -le $Qle)} | New-Partition -UseMaximumSize -DriveLetter "Q" | Get-Partition | Format-Volume -FileSystem NTFS -NewFileSystemLabel "Q Disk" -Force |
6.2.4
Other node configuration : Initialize the production iSCSItarget virtual disk for the configuration node (初始化其他节点的 “仲裁” Iscsi 目标虚拟磁盘)
1 2 3 4 5 6 7 8 9 10 |
# 定义:获取磁盘 | 空间为 9-10 之间大小的磁盘 | 对象操作 指定磁盘序列号 $QDiskNum = Get-Disk | Where-Object {($_.Size -ge $Qge) -and ($_.Size -le $Qle)} | ForEach-Object {$_.Number } # 定义:获取 Win32类 磁盘分区类 | 指定对象为:磁盘索引号 和 磁盘类型 | 对象操作 磁盘大小 $Size = Get-WmiObject Win32_DiskPartition | Where-Object {($_.Diskindex -eq $QDiskNum ) -and ($_.Type -eq "GPT: Basic Data")} | ForEach-Object {$_.Size } # 获取分区 | 对象:指定分区大小为指定空间 | 设置分区 新建分区编号为 Q Get-Partition | Where-Object {$_.Size -eq "$Size" } | Set-Partition -NewDriveLetter "Q" |