Categories
General

vSphere : PowerCLI Multipath Config

vSphere : PowerCLI Multipath Config

Round-robin configuration is per LUN, per host with vCenter 4.X and ESXi 4.x. When multiple hosts and datastores are in use this is a cumbersome and long-winded configuration that can easily be simplified with PowerCLI.

Single Host Configuration

Open PowerCLI and connect to a/the VCENTER server in your environment, change vcenter_name to match the hostname of your server:

connect-VIServer vcenter_name

To view hosts in a cluster, chage the cluster_name to match that in the vCenter GUI:

get-cluster cluster_name | get-vmhost

Confirm disks attached to each host:

get-cluster cluster_name | Get-VMHost | Get-ScsiLun -LunType disk

In the case of the environment I was working in I only wanted to change the configuration for EVA8400 disks attached to the VM hosts. There were also non-active/active storage devices attached which could not use round-robin.

To view the CanonicalName for all LUNs I used the command:

get-cluster cluster_name | Get-VMHost | Get-ScsiLun -LunType disk | fl -show canonicalname,vendor,capacitymb,model,luntype

From this you can analyse the CanonicalName and find the volumes that share the fist few digits, I ended up with all EVA8400 LUNs sharing ‘naa.6001438005’. An example output is below, you’ll note that two of the three LUNs share CanonicalName string (in red), the other does not (in green):

CanonicalName : naa.600508b1001c3a986c7a228dcad5099b
Vendor : HP
CapacityMB : 57207
Model : LOGICAL VOLUME
LunType : disk
MultipathPolicy : MostRecentlyUsed

CanonicalName : naa.6001438005dee9f70000600003cf0000
Vendor : HP
CapacityMB : 153600
Model : HSV450
LunType : disk
MultipathPolicy : RoundRobin

CanonicalName : naa.6001438005deea3c0000900002a00000
Vendor : HP
CapacityMB : 102400
Model : HSV450
LunType : disk
MultipathPolicy : RoundRobin

Once you have identified which disks you want to change, confirm the string is working – adding a ‘*’ to the end of it, for example in order for me to view the EVA 8400 disks attached to a host:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*”

CanonicalN ConsoleDeviceName LunType CapacityMB MultipathPolicy
ame
———- —————– ——- ———- —————
naa.600… /vmfs/devices/disks/naa.600… disk 102400 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 153600 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 153600 RoundRobin
naa.600… /vmfs/devices/disks/naa.600… disk 230400 RoundRobin

I had four LUNs presented from the EVA8400, so I knew this was working, I had also configured these to be RoundRobin already. This enabled quick identification that these were the correct volumes. You can use the following script to map CanonicalName to DatastoreName as per the vCenter console as can be found here: http://communities.vmware.com/message/1435173#1435173

$h = Get-VMhost hostname

# collect VMFS datastore name and extent cannonical names into a hashtable
$dsLunList = @{}
$dsView = $h | Get-Datastore | ? {$_.Type -eq “VMFS”} | Get-View
foreach ($ds in $dsView) {
foreach ($diskExtent in $ds.Info.Vmfs.Extent) {
$dsLunList[$diskExtent.DiskName] = $ds.Info.Name
}
}

#populate datastore name for each lun if available
$lunList = @()
$h | Get-ScsiLun | % {
$lun = “” | select ConsoleDeviceName, CanonicalName, DatastoreName
$lun.ConsoleDeviceName = $_.ConsoleDeviceName
$lun.CanonicalName = $_.CanonicalName

if ($dsLunList.ContainsKey($_.CanonicalName)) {
$lun.DatastoreName = $dsLunList[$_.CanonicalName]
}

$lunList += $lun
}

$lunList | ft -show CanonicalName,DatastoreName

Confirm EVA LUN’s that are not configured for RoundRobin multipathing:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”}

To modify the LUN multipathing configuration you can use the following command:

$vmhost = get-VMhost hostname

Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”

Multiple Host Configuration

To perform this for each node in a VM cluster use the following commands:

foreach ($vmhost in get-cluster cluster_name | get-vmhost) {
Get-VMHost $vmhost | Get-ScsiLun -CanonicalName “naa.6001438005*” | Where {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “roundrobin”
}

Additional Information

naa.6001* is a HP storage device

naa.6006* is an EMC storage device

Leave a Reply

Your email address will not be published. Required fields are marked *