批量修改vsphere共享儲存多路徑選擇策略

吳諾克發表於2021-01-01

傳統方式修改儲存的多路徑選擇策略

首先說一下傳統web介面操作方式:

可以看到至少需要6次才能修改完成一個。在生產環境中一般會掛載很多FC儲存,這時候就需要一個批量快捷的方式來修改。

使用Powercli批量修改儲存多路徑選擇策略

  • 使用 get-vmhost | get-scsilun 可以看到當前所有主機連線的FC多路徑策略。
PS D:\> get-vmhost | get-scsilun

CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame
---------- -----------------              -------         ---------- ---------------
naa.650... /vmfs/devices/disks/naa.650... disk             2,234.500 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.650... /vmfs/devices/disks/naa.650... disk             2,234.500 Fixed
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
mpx.vmh... /vmfs/devices/disks/mpx.vmh... disk                 0.000 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 Fixed
......

可以看到很多都是"Fixed(固定)"狀態,一般來說建議改為"RoundRobin(迴圈)"

  • 配合使用Set-ScsiLun -MultipathPolicy RoundRobin可以批量將多路徑策略改為"RoundRobin(迴圈)"模式
PS D:\> Get-Cluster -Name Cloud_Production_Cluster | Get-VMHost | Get-ScsiLun| Set-ScsiLun -MultipathPolicy RoundRobin
CanonicalN ConsoleDeviceName              LunType         CapacityGB MultipathPolicy
ame
---------- -----------------              -------         ---------- ---------------
naa.650... /vmfs/devices/disks/naa.650... disk             2,234.500 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.650... /vmfs/devices/disks/naa.650... disk             2,234.500 RoundRobin
naa.600... /vmfs/devices/disks/naa.600... disk             3,071.935 RoundRobin
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 RoundRobin
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 RoundRobin
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 RoundRobin
naa.500... /vmfs/devices/disks/naa.500... disk             1,117.813 RoundRobin
mpx.vmh... /vmfs/devices/disks/mpx.vmh... disk                 0.000 RoundRobin
......

引數說明:

  • Get-Cluster -Name Cloud_Production_Cluster 指定叢集
  • Get-VMHost 所有主機
  • Get-ScsiLun 得到LUN資訊
  • Set-ScsiLun -MultipathPolicy 設定為MultipathPolicy 為RoundRobin OR Fixed模式

參考:[1]https://code.vmware.com/docs/1507/vmware-powercli

相關文章