Contributor
Contributor

Switching PSP from fixed to round-robin using esxcli

I know how to set the default path selection policy to round-robin using esxcli (esxcli nmp satp

setdefaultpsp --satp VMW_SATP_DEFAULT_AA --psp VMW_PSP_RR) but is it also possible to switch from fixed to round-robin for individual datastores using esxcli? That way I could loop through all the datastores and switch to RR without requiring a reboot on each ESX. It is possible to change to RR in the vSphere Client GUI, but that would be too much work for about 70 different datastores. An aequivalent PowerCLI script would be fine too. Thanks in advance!

0 Kudos
7 Replies
Immortal
Immortal

here's what we use when building our environment. We connect to a individual ESX Host

Get-ScsiLun -VmHost (Get-VMHost) -LunType disk |  Set-ScsiLun -MultipathPolicy "roundrobin"

this also works

$Mypolicy = "rr"
 
Get-Datastore | where {$_.Type -eq "VMFS"} | %{(Get-View $_.ID).Info.Vmfs.Extent[0].DiskName} |%{
  $diskname = $_
  Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.storageSystem} | %{
    $mpathpolicy = New-Object vmware.vim.HostMultipathInfoLogicalUnitPolicy
    $mpathpolicy.policy = $Mypolicy
    $_.SetMultipathLunPolicy($diskname,$mpathpolicy)
  }
}

Community Manager
Community Manager

You would still use esxcli to perform this change whether it's setting the default PSP globally or for a given device.

In this case, if you want to set it on a particular datastore, you'll want to do the following:

1) Figure out the device (datastore) you want to set PSP on, you can list all available devices by running:

esxcli nmp device list

2) Once you've figured out the device, then you'll set the appropriate policy:

esxcli nmp device setpolicy --device naa.500000e11053d940 --psp VMW_PSP_RR

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
Contributor
Contributor

That's exactly the command that I was looking for, thank you very much! One question though: after changing to RR for a device, the command esxcli nmp device list correctly shows Path Selection Policy: VMW_PSP_RR but the vSphere Client GUI doesn't: Configuration > Storage > Properties... > Manage Paths... still shows "Fixed (VMware). Is that a known bug or something?

0 Kudos
Community Manager
Community Manager

I believe you also need to refresh the storage sub-system on the host to get the changes reflect on the GUI. Did you try to refresh via the GUI or try to re-connect using the vSphere Client?

You can also try to refresh the storage sub-system by using vmware-vim-cmd (vimsh):

vmware-vim-cmd hostsvc/storage/refresh

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware VCP3,4

VMware VCAP-DCA4

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
Contributor
Contributor

Created a oneliner so that you can "generate" the cli for all the disk

for disk in $(esxcli nmp device list | grep -B2 -e "Storage Array Type:   VMW_SATP_SVC" | grep -e "^naa"); do echo "esxcli nmp device setpolicy   --device $disk --psp VMW_PSP_RR";done;

change VMW_SATP_SVC to your storage array specific type. You can copy the output to similar esx hosts

blogged on : http://tendertechie.blogspot.com/2011/01/another-esxcli-oneliner.html

0 Kudos
Contributor
Contributor

With vSphere 5 and ESXi 5 hosts, things changed a bit with the esxcli command :

1. To change the path policy for each iSCSI connection :

for disk in $(esxcli storage nmp device list | grep -B2 -e "Storage Array Type: VMW_SATP_EQL" | grep -e "^naa"); do echo "esxcli storage nmp device set -d $disk -P VMW_PSP_RR";done;

2. To change de default path policy to Round Robin, you should use :

esxcli storage nmp satp set -s VMW_SATP_DEFAULT_AA -P VMW_PSP_RR

esxcli storage nmp satp set -s VMW_SATP_EQL -P VMW_PSP_RR

3. To get a list of all plugin path :

~ # esxcli storage nmp psp list
Name           Description                     
-------------  ---------------------------------
VMW_PSP_MRU    Most Recently Used Path Selection
VMW_PSP_RR     Round Robin Path Selection      
VMW_PSP_FIXED  Fixed Path Selection

4. And to get to know the default path policy associated with each storage type plugin :

~ # esxcli storage nmp satp list
Name                 Default PSP       Description                              
-------------------  ----------------  ------------------------------------------
VMW_SATP_EQL         VMW_PSP_RR        Supports EqualLogic arrays               
VMW_SATP_MSA         VMW_PSP_MRU       Placeholder (plugin not loaded)          
VMW_SATP_ALUA        VMW_PSP_MRU       Placeholder (plugin not loaded)          
VMW_SATP_DEFAULT_AP  VMW_PSP_MRU       Placeholder (plugin not loaded)          
VMW_SATP_SVC         VMW_PSP_FIXED     Placeholder (plugin not loaded)          
VMW_SATP_INV         VMW_PSP_FIXED     Placeholder (plugin not loaded)          
VMW_SATP_EVA         VMW_PSP_FIXED     Placeholder (plugin not loaded)          
VMW_SATP_ALUA_CX     VMW_PSP_FIXED_AP  Placeholder (plugin not loaded)          
VMW_SATP_SYMM        VMW_PSP_FIXED     Placeholder (plugin not loaded)          
VMW_SATP_CX          VMW_PSP_MRU       Placeholder (plugin not loaded)          
VMW_SATP_LSI         VMW_PSP_MRU       Placeholder (plugin not loaded)          
VMW_SATP_DEFAULT_AA  VMW_PSP_RR        Supports non-specific active/active arrays
VMW_SATP_LOCAL       VMW_PSP_FIXED     Supports direct attached devices      

Hope that helps,

Mini.

0 Kudos
Contributor
Contributor

Your scripted part didn't work for me.  It would enumerate most, but not all storage, and change none of them.  I found it simpler to just set the default as per your item 2, and them reboot the host.  That was a lot quicker and simpler than manually changing each datastore - we had 28 in this cluster so I certainly didn't want to touch 8x28 datastores.  It does seem to re-enumerate the datastores with the reboot, so very little work actually needs done to enable this.

0 Kudos