Tuesday, January 19, 2010

Use Powershell to set Round Robin Multipathing

So as we start moving to vSphere 4 I am sure most of us are going to want to start using the new mulitpathing policy of Round Robin...to use all available paths to our storage. I have one cluster with about 32 LUNS in it so making that change for each of the 12 Servers in the cluster was going to be a pain.

But it appears someone has already made life easy. Check out this powershell script that does all the magic. Now it takes a little time to run..but it certainly was faster than using the GUI to make all them changes.
Below is the actual code I used (small change from the link--apparently get-viserver is not valid any longer). This connects to your vCenter then to the server on the 2nd line of the script (testvsphere in this case), then goes through all the LUNS that have 2 or more paths, and sets it to the Round Robin policy. You can watch the progress in tasks pane at the bottom of vCenter.

Connect-VIServer vcenter.nh.novant.net
$h = get-vmhost testvsphere.nh.novant.net
$hostView = get-view $h.id
$policy = new-object VMware.Vim.HostMultipathInfoLogicalUnitPolicy
$policy.policy = "rr"
$storageSystem = get-view $hostView.ConfigManager.StorageSystem
$storageSystem.StorageDeviceInfo.MultipathInfo.lun |
where { $_.Path.length -gt 1 } |
foreach { $storageSystem.SetMultipathLunPolicy($_.ID, $policy) }

No comments:

VMware RSS Feed