VMware: Configure Multipath Policy via PowerCLI
Tonight I need to configure the Multipath Policy from “Most Recently Used” to “Round Robin (VMware) on our vSphere 4.1 and HP EVA6400 environment. After reading “Configuration best practices for HP StorageWorks Enterprise Virtual Array (EVA) family and VMware vSphere 4” I decided to change the path status
To check the status of the Multipath Policy you can run the following PowerCLI script:
Per host:
Get-VMhost ESXHOST | Get-ScsiLun -LunType disk
Per Cluster:
Get-Cluster CLUSTERNAME| Get-VMHost | Get-ScsiLun -LunType disk
To change the Multipath Policy you can run the following command:
Per Host:
Get-VMHost ESXHOST | Get-ScsiLun -CanonicalName "naa.6005*" | Set-ScsiLun -MultipathPolicy "roundrobin"
Result in vCenter:
Can also do this by using the vSphere Management Assistant before connecting SAN LUN’s to your vsphere host so all LUN’s are default presented with path policy RR:
esxcli –server nmp satp setdefaultpsp –satp=”VMW_SATP_DEFAULT_AP” –psp=”VMW_PSP_RR”
Also read this thread for setting iops for HP EVA array’s:
http://vmug.nl/modules.php?name=Forums&file=viewtopic&t=4893
Great post, used this for my environmet
Here is a faster one-liner:
get-cluster “Cluster Name” | Get-VMHost | Get-ScsiLun -LunType disk | Where-Object {$_.MultipathPolicy -ne “RoundRobin”} | Set-ScsiLun -MultipathPolicy “RoundRobin”
Thanks Robert!
Robert,
Your faster one-liner worked for me, but only made the change for the first host in my cluster. The second host remained as it was with some paths as ‘fixed’. I’m fairly new to both PowerShell and PowerCLI, so any help would be appreciated.
Thanks,
Doug
Great information, helped in setting for 12 hosts each with 32 disks.
I wanted to know if there is way to get the LUN nos with the canonical names.
Thanks,
Suhail.
The PSP for vSphere 5
esxcli storage nmp satp set –default-psp VMW_PSP_RR –satp VMW_SATP_ALUA
Just applied this one liner no issues works fine in vsphere 5.
My vCenter server having multiple virtual Data center and multiple cluster, so what is the single command to get detail of All DataStore Multi path policy
This is for vSphere 5.1
$strHost = Get-VMHost
connect-viserver $strHost
$esxcli = $strHost | Get-EsxCLI
$esxcli.storage.nmp.satp.set($null,”VMW_PSP_RR”,”VMW_SATP_ALUA”)
$strHost | Get-ScsiLun -CanonicalName “naa.6001*” | Set-ScsiLun -Multipathpolicy “roundrobin”
$esxcli.storage.nmp.device.list() | Where {$_.PathSelectionPolicy -eq “VMW_PSP_RR”} | %{$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set($null,$true, $_.device, 1,”iops”,$null)}
$esxcli.storage.nmp.device.list() | Where {$_.PathSelectionPolicy -eq “VMW_PSP_RR”} | %{$esxcli.storage.nmp.psp.roundrobin.deviceconfig.get($_.device)}
Thanks Brian!
The result is not completely visible with the comannd Get-VMhost ESXHOST | Get-ScsiLun -LunType disk
How can I make the display completely for the ConsoleDeviceName and CanonicalName
Thanks, Kroman
@Kroman
Get-SCSILun -VMhost “ESXi host name” -LunType Disk | Select CanonicalName,CapacityGB,runtimename,MultipathPolicy
this really saved us A LOT OF time! thank you!!!!