- Advertisement -
HomeVirtualizationVMwarePowerCLI + VMware 6.7 Storage Best Practices

PowerCLI + VMware 6.7 Storage Best Practices

In this blog post, I want to share some of the most used best practices when working with storage arrays and VMware ESXi hosts, using PowerCLI. These configurations, are in particular for AFAs on iSCSI.

Is not my intention to explain the benefits and behaviors when these settings are modified (maybe in another blog post), just the PowerCLI script reference and steps. PowerCLI is extremely useful to work with larges environments (clusters). If you are setting a single ESXi, I’d use ESXCLI commands via an SSH Terminal, my personal preference.

Note: These are general recommendations from VMware and most of the storage (AFA) vendors. But you need to take into account that every vendor may suggest a different configuration. Also, are specific scenarios in which these best practices might not apply.

I took some of these scripts around the web and modified most of them. All these best practices could be written and run in a single script, but because of what I mentioned before, I prefer to keep each script separated, so you can test individually and troubleshoot if needed.

PowerCLI: Install and connect

Install PowerCLI

- Advertisement -

1. Open the Windows PowerShell console.

2. Install all official PowerCLI modules, running the following command.

Install-Module VMware.PowerCLI -Scope CurrentUser

Connect to the Cluster

1. Open the Windows PowerShell console.

- Advertisement -

2. Replace the bolded text and run the following command to connect to your vCenter Server.

connect-viserver -server Your_vCenter_IP -user Your_User -password Your_Password

Best Practices with PowerCLI

Change the Path Selection Policy to Round Robin

Current iSCSI LUNs

1. Connect to the vCenter Server using PowerCLI.

2. Replace Cluster_Name, copy and run the commands below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

foreach ($esxhost in $AllHosts) {Get-VMHost $esxhost | Get-ScsiLun -LunType disk | Where-Object {$_.CanonicalName -like "eui.*"} | Set-ScsiLun "RoundRobin" | Select-Object VMHost, CanonicalName, MultipathPolicy}

For new LUN Creation

With this option you will set all ESXi hosts to automatically configure Round Robin to all the new recognized Volumes/LUNs.

1. Connect to the vCenter Server using PowerCLI.

- Advertisement -

2. Replace Cluster_Name and run the commands below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

foreach ($esxhost in $AllHosts) {$esxcli = get-esxcli -vmhost $esxhost; $esxcli.storage.nmp.satp.set($null,"VMW_PSP_RR","VMW_SATP_ALUA")}

Round Robin I/O Operations Limit

Change the Round Robin I/O Operation Limit from 1,000 to 1. From the latest VMware Best Practices, VMware considers the default setting is enough to provide good performance.

1. Connect to the vCenter Server using PowerCLI.
2. Replace Cluster_Name and run the commands below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

foreach ($esxhost in $AllHosts) {Get-VMHost $esxhost | Get-ScsiLun -LunType disk | Where-Object {$_.Multipathpolicy -like "RoundRobin"} | Set-ScsiLun -CommandsToSwitchPath 1 | Select-Object VMHost, CanonicalName, MultipathPolicy, CommandsToSwitchPath}

Changing Disk.MaxIOSize to 4,096KB

1. Connect to the vCenter Server using PowerCLI.
2. Replace Cluster_Name and run the command below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

3. Set the Disk.DiskMaxIOSize value to 4096 with the command below.

foreach ($esxhost in $AllHosts) {$esxcli = get-esxcli -vmhost $esxhost; $esxhost | get-AdvancedSetting -Name "disk.diskmaxiosize" | set-AdvancedSetting -Value "4096" -Confirm:$false | Select-Object Name, Value}

Set Login Timeout to 30

1. Connect to the vCenter Server using PowerCLI.

2. Replace Cluster_Name and run the commands below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

$hba = Get-VMHostHba -VMHost $esxhost -Type iScsi | Where-Object {$_.Model -like "iSCSI Software Adapter"}

3. Set the LoginTimeout value of the iSCSI Software Adapter to 30 with the command below.

foreach ($esxhost in $AllHosts) {$esxcli = get-esxcli -vmhost $esxhost; $esxcli.iscsi.adapter.param.set($hba.device,$false,'LoginTimeout','30')}

Disable DelayedAck

1. Connect to the vCenter Server using PowerCLI.

2. Replace Cluster_Name and run the commands below.

$AllHosts = Get-Cluster Cluster_Name | Get-VMHost | where {($_.ConnectionState -like "Connected" -or $_.ConnectionState -like "Maintenance")}

$hba = Get-VMHostHba -VMHost $esxhost -Type iScsi | Where-Object {$_.Model -like "iSCSI Software Adapter"}

3. Disable the DelayedAck value of the iSCSI Software Adapter with the command below.

foreach ($esxhost in $AllHosts) {$esxcli = get-esxcli -vmhost $esxhost; $esxcli.iscsi.adapter.param.set($hba.device,$false,'DelayedAck', '0')}

VAAI

VAAI is enabled by default. You can check the VAAI status, enable and disable VAAI with PowerCLI.

1. Connect to the vCenter Server using PowerCLI.

2. Replace Cluster_Name and run the commands below.

These commands will call the primitives XCOPY, WRITE_SAME, and ATS, respectively.

VAAI status

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking

Enable VAAI

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove | Set-AdvancedSetting -Value 0 -Confirm:$false

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit | Set-AdvancedSetting -Value 0 -Confirm:$false

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking | Set-AdvancedSetting -Value 0 -Confirm:$false

Disable VAAI

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove | Set-AdvancedSetting -Value 1 -Confirm:$false

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit | Set-AdvancedSetting -Value 1 -Confirm:$false

Get-Cluster Cluster_Name | Get-VMHost | Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking | Set-AdvancedSetting -Value 1 -Confirm:$false

Juan Mulford
Juan Mulford
I have been active in IT for over fourteen years now. I am a solutions architect, working with storage, virtualization, and VDI solutions. For the past ten years, I have been living and working in Taiwan.

2 COMMENTS

  1. Juan, two questions:
    1) Do any of these changes require a host reboot to take effect?
    2) Did you ever write an article identifying the benefit of each setting, or at least where the recommendation comes from?

    Thanks!

    • Hi Nelson,
      1. If I recall correctly, none of these changes require reboot.
      2. I did not. The recommendation comes from VMware, read the first note and follow the link in the Round Robin section. VMworld on demand videos refers to this topic nicely. From 2017, I think.

Leave a Reply

- Advertisement -

Popular Articles

mulcas.com-Raspberry-Pi

Raspberry Pi OS in a Virtual Machine with VMware

4
Although the Raspberry Pi OS is designed and optimized for the Raspberry Pi module, it is possible to test and use it without its hardware, with VMware. This solution can be useful if you are a developer (or just a curious guy) and don't have a Raspberry Pi module with you
Unable to delete inaccessible datastore

Unable to delete an "inaccessible" datastore

7
I was switching my storage array, so I migrated the VMs from that old datastore/storage to a new datastore/storage. The old datastore was shared by 3 ESXi hosts, no cluster. After migrating the VMs and unmount/delete the datastore, it was still presented in two of the ESXi hosts and was marked as inaccessible.
This is not a valid source path / URL

This is not a valid source path / URL - SourceTree and Gitlab

0
I have been working on a project with a friend who set up a repository in Gitlab but even though I was able to view all projects on it, I couldn’t really join the repository. I was using SourceTree and Gitlab.
mulcas.com-VMware-OVF-Tool

How to export a Virtual Machine using the VMware OVF Tool

9
The VMware OVF Tool is implemented by VMware for easily importing and exporting virtual machines in Open Virtualization Format (OVF) standard format. Here, I want to show you how to download and install it, and then how to use it from a Windows machine.
Couldn't load private key - Putty key format too new

Couldn't load private key - Putty key format too new

5
couldn't load private key - Putty key format too new.” This issue happens when you use PuTTygen to generate or convert to a ppk key. Here is how to fix it. 
- Advertisement -

Recent Comments