ScriptVMware

Correcting Multi Path Policy

Correcting Multi Path Policy(MPP), is some thing i had to do recently – The story goes… The storage team had brought in a new storage array/vendor and started making datastores from that, now a few hundred datastores later, someone noticed that some path where highly utilized while others again was hardly used at all. So after looking into this, it was desisted to change the Multi Path Policy to RoundRobin as per the vendors recommendations and best practices. While making the script for this I noticed that some local disks were already set to RoundRobin where they were suppose to be configured as Fixed. So I created the below script to correct the issue. It takes a while to get the job done, but in the end it way faster than the alternatives.

$LUNS = Get-VMHost -Location <ClusterName> | Get-ScsiLun -LunType "disk"
foreach($lun in $luns){
if($lun.IsLocal -eq $True){
$lun | where {$lun.MultipathPolicy -ne "Fixed"} |Set-ScsiLun -MultipathPolicy Fixed -PreferredPath ($lun | Get-ScsiLunPath).name
}
elseif($lun.IsLocal -eq $False){
$lun | where {$lun.MultipathPolicy -ne "RoundRobin"} |Set-ScsiLun -MultipathPolicy RoundRobin
}
}

 

Ps. Don’t forget this was just to fix the problem for the current datastores, that have already been added to the environment. This does not fix the overall problem that the default Path Selection Plugin(PSP) policy is incorrect and needs to be changed. This can be done with the following command

esxcli storage nmp satp set --default-psp=policy --satp=your_SATP_name

You can read more about it in the VMware KB 1017760 here

 

UPDATE: Removed the -Whatif statement at the end of the two lines beginning with $lun

Leave a Reply

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