At work we have started to make a push to get as many servers off of RDM (Raw Device Mapping) drives in the virtual environment as we can. We use the RDM drives with MSCS (Microsoft Server Cluster Service) with SQL, but we do have a few application failover cluster as well. With this change we have an influx of iSCSI (Internet Small Computer Systems Interface) drive configurations along with MPIO (Multipath I/O) configured. With most configurations of iSCSI it should be configured with multiple paths to help mitigate the effects of HBA (host bus adapter) failure. So to ensure that everybody on the team configures the iSCSI and MPIO the same, I have scripted the setup and configuration of it. This has reduced the configuration time from about 5-10 minutes per server to about 30 seconds.
Step 1. Configure iSCSI and MPIO
[PS]
get-service -name MSiSCSI | start-service Set-Service -Name msiscsi -StartupType Automatic
Install-WindowsFeature -name Multipath-IO
[/PS]
The first two lines of this snippet starts the iSCSI service, and changes the start up setting to automatic. The third line of this will install the windows feature for MPIO.
Step 2. Gather the Initiator ID
(get-initiatorport).nodeaddress
This command gets the iSCSI Initiator ID. This is the information that I pass to the storage team for them to do their work to provision the iSCSI LUN to this machine.
Step 3. Finish the iSCSI/MPIO configuration
This is where the magic happens. This part of the configuration goes very quickly with a this script.
$TargetPortalAddresses = @("192.168.10.6","192.168.10.7","192.168.10.8","192.168.10.9") $LocaliSCSIAddress = "192.168.10.100" Foreach ($TargetPortalAddress in $TargetPortalAddresses){ New-IscsiTargetPortal -TargetPortalAddress $TargetPortalAddress -TargetPortalPortNumber 3260 -InitiatorPortalAddress $LocaliSCSIAddress } New-MSDSMSupportedHW -VendorId MSFT2005 -ProductId iSCSIBusType_0x9 Foreach ($TargetPortalAddress in $TargetPortalAddresses){ Get-IscsiTarget | Connect-IscsiTarget -IsMultipathEnabled $true -TargetPortalAddress $TargetPortalAddress -InitiatorPortalAddress $LocaliSCSIAddress -IsPersistent $true } Set-MSDSMGlobalDefaultLoadBalancePolicy -Policy FOO
Breakdown of the script
The first line has the iSCSI initiators from the storage side
$TargetPortalAddresses = @("192.168.10.6","192.168.10.7","192.168.10.8","192.168.10.9")
This line is the local IP address that connects the server to the iSCSI initiators
$LocaliSCSIAddress = "192.168.10.100"
This generates the Portal Addresses based on the the number and IP addresses of $TargetPortalAddresses in the first line of the script.
Foreach ($TargetPortalAddress in $TargetPortalAddresses){ New-IscsiTargetPortal -TargetPortalAddress $TargetPortalAddress -TargetPortalPortNumber 3260 -InitiatorPortalAddress $LocaliSCSIAddress }
This line enabled MPIO support for iSCSI
New-MSDSMSupportedHW -VendorId MSFT2005 -ProductId iSCSIBusType_0x9
This for-each loop makes the connections to the iSCSI drives and sets the multipath to be enabled.
Foreach ($TargetPortalAddress in $TargetPortalAddresses){ Get-IscsiTarget | Connect-IscsiTarget -IsMultipathEnabled $true -TargetPortalAddress $TargetPortalAddress -InitiatorPortalAddress $LocaliSCSIAddress -IsPersistent $true }
The last line sets the failover policy to Failover only via MPIO
Set-MSDSMGlobalDefaultLoadBalancePolicy -Policy FOO
-Stuart
Find this script at GitHub.com