Hello:
I want to set up RR policy on all my LUNs at once (at VI4)...
I thought this script should do it (I took it from http://blogs.vmware.com/vipowershell/2008/07/managing-storag.html):
$VCimpl = Connect-VIServer "VCenter"
$policy = new-object VMware.Vim.HostMultipathInfoFixedLogicalUnitPolicy
$policy.policy = "rr"
$storageSystem.StorageDeviceInfo.MultipathInfo.lun |
where { $_.Path.length -gt 1 } |
foreach { $storageSystem.SetMultipathLunPolicy($_.ID, $policy) }
But it does not do anything, no error either...
How should I adjust it to be able set RR an all LUNs.
Thanks
Can't you use
Get-ScsiLun -VmHost (Get-VMHost $esxName) -LunType disk | Set-ScsiLun -MultipathPolicy "roundrobin"
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Can't you use
Get-ScsiLun -VmHost (Get-VMHost $esxName) -LunType disk | Set-ScsiLun -MultipathPolicy "roundrobin"
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Luc,
Your help is amazing as usual!!! Thanks a lot!
Just small addition…
When I run this command I had error “Item has already been added. Key in dictionary: 'Misc.LogToFile' Key being added: 'Misc.LogToFile'
After some research I found that I need to upgrade vSphere PowerCLI to latest version 4.0.1.2164 (I had 4.0.0) and everything started running just fine.
Thanks again!
How does one go about specifying a group or LUNs or LUNs that have a common key word in them?
You can for example use a Where-Object cmdlet to only select the LUNs you need.
For example, the following line only selects the LUNs where the CanonicalName starts with "naa."
Get-ScsiLun -VmHost (Get-VMHost $esxName) -LunType disk | where{$_.CanonicalName -like "naa.*"} | Set-ScsiLun -MultipathPolicy "roundrobin"
What specific selection criterium are you looking for ?
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks! I love easy solutions.
Is there any way to do it by the name of the LUN?
I tried Get-ScsiLun -VmHost (Get-VMHost "hostname") -LunType disk | where{$_.StartsWith("XIV")}, which fails.
I'm not sure I understand what you mean by name of the LUN.
If you do the following, which property do you mean ?
Get-ScsiLun -VmHost (Get-VMHost "hostname") -LunType disk | Select *
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I mean the datastore name.
Try the following script, it allows you to specify one or more datastore names and it will set the path policy for those to round-robin.
function Get-LunDatastoreHash{ param($VMHost) $lunTab = @{} $hss = Get-View ($VMHost | Get-View).ConfigManager.StorageSystem foreach($mount in $hss.FileSystemVolumeInfo.MountInfo){ if($mount.Volume.Type -eq "VMFS"){ foreach($ext in $mount.Volume.Extent){ foreach($lun in $hss.StorageDeviceInfo.MultipathInfo.Lun){ if(($hss.StorageDeviceInfo.ScsiLun | where{$_.Key -eq $lun.Lun}).CanonicalName -eq $ext.DiskName) { foreach($Path in $lun.path){ if ($Path.pathstate -eq "active"){ $activepath = $path.name break } } break } } $lunTab[http://$ext.DiskName|http://$ext.DiskName] = $mount.Volume.Name } } } $lunTab } $esxName = <esx-name> $targetDS = <ds> # Can have multiple dsnames; <ds1>,<ds2>... $esx = Get-VMHost -Name $esxName $lookupTab = Get-LunDatastoreHash -VMHost $esx Get-ScsiLun -VmHost $esx -LunType disk | where{$targetDS -contains $lookupTab[http://$_.CanonicalName|http://$_.CanonicalName]} | Set-ScsiLun -MultipathPolicy "roundrobin"
I attached the script since it contains square brackets and the forum SW doesn't like these.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is great! Thank you for your effort.
Any chance you can show us a quick easy way to just show the ones that aren't round robin? Mine are done but would like to be able to run something after host's have been rebooted that will verify that they are set to round robin.
Jeff
here's what I use... simple but effective
Get-VMHost | %{ $esxImpl = $_ $_ | Get-ScsiLun | where {$_.LunType -eq "Disk"} | %{ $_ | Select @{N="HostName";E={$esxImpl.Name}}, @{N="Path";E={$_.CanonicalName}}, @{N="Policy";E={$_.MultiPathPolicy}}, @{N="Number";E={($_ | Get-ScsiLunPath).Count}} } }|Export-Csv "C:\scripts\ds.csv" -NoTypeInformation
Hi there guys, I hope you guys are still around,,, I had an HP EVA that began to lun thrash and I found out that my predessor hadn't set the luns to round-robin. I found Luc's Power Shell and got them all changed. So since the change, I've see some performance lag on IOPS on a few sql servers. I read this:
To optimize EVA array performance, HP recommends changing the default round robin load balancing IOPS value to 1. This update must be performed for every Vdisk using the following command on ESX4.x:
esxcli nmp roundrobin setconfig -t iops -I 1 -d naa.xxxxxxxxx
Luc, if you're still out there,, is there a way to write a powershell to change this on all the luns like the round-robin command you posted up at the top??
This IOPS=1 setting has been under some discussion lately.
See Duncan's blog post What’s the point of setting “–IOPS=1″ ?
In any case, to set the value, you can use the Get-EsxCli cmdlet.
The thread How to configure IOPS with powerCLI should help you. Have a look.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Wow, thanks for the quick reply Luc! I guess from that thread I won't gain much improvement on that server.. I don't get why IOPS tanks so bad on that guest? Changing it back to Fixed should have made it worse..
I recently wrote a blog post about using PowerCLI to configure all LUNs to Round Robin:
The command boils down to this:
Get-VMHost | Get-ScsiLun -LunType disk | Where {$_.MultipathPolicy -notlike "RoundRobin"} | Where {$_.CapacityGB -ge 100} | Set-Scsilun -MultiPathPolicy RoundRobin
It finds all "disks" that are currently not configured as "RoundRobin" and are larger than "100" GB (to avoid my direct attached disk on each ESXi host), then changes their MultipathPolicy to Round Robin.