VMware Cloud Community
justinsmith
Enthusiast
Enthusiast

Script to change NFS default max mounts

So by default...  ESXi hosts are configured for 8 NFS volumes and a TCPIP Heap Size of 16 and a TCPIPMax of 64.

VMWare has a KB how to change those to 64 max volumes, 32 TCPIP Heap Size and 120 TCPIPMax... what Im looking for is a script to do this for me to a cluster, automatically....

Obviously, those changes need to be made by a reboot... which I can do manually, no problem.

Thanks scripters!

Reply
0 Kudos
8 Replies
alanrenouf
VMware Employee
VMware Employee

Can you link to the KB so I get the correct setting please.

Basically you would use something like this:

Set-VMHostAdvancedConfiguration -VMHost ESX1 -Name NFS.MaxVolumes -Value 64
Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
justinsmith
Enthusiast
Enthusiast

Id like to set these changes for all the ESX hosts in a specific cluster too....

Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee

Ok so for a cluster this would be:

Get-Cluster Cluster1 | Get-VMHost | Foreach {

     Set-VMHostAdvancedConfiguration -VMHost $_ -Name NFS.MaxVolumes -Value 64

     Set-VMHostAdvancedConfiguration -VMHost $_ -Name Net.TcpIpHeapSize -Value 32

     Set-VMHostAdvancedConfiguration -VMHost $_ -Name Net.TcpIpHeapMax -Value 120

}

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee

Of course you could add a Restart-VMHost $_  -Confirm:$False before the end of the loop to restart the host.

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
justinsmith
Enthusiast
Enthusiast

The first portion seems to work (Set-VMHostAdvancedConfiguration -VMHost $_ -Name NFS.MaxVolumes -Value 64)

But the second and 3rd config change error out.

Set-VMHostAdvancedConfiguration : 6/23/2011 12:10:17 PM    Set-VMHostAdvancedCo
nfiguration        A specified parameter was not correct.

At C:\Documents and Settings\jsmith\Desktop\PowerShell Scripts\NFS Defau
lt Changes.ps1:3 char:37
+      Set-VMHostAdvancedConfiguration <<<<  -VMHost $_ -Name Net.TcpIpHeapSize
-Value 32
    + CategoryInfo          : NotSpecified: (:) [Set-VMHostAdvancedConfigurati
   on], InvalidArgument
    + FullyQualifiedErrorId : Client20_MoServiceImpl_Invoke_ViError,VMware.Vim
   Automation.ViCore.Cmdlets.Commands.Host.SetVMHostAdvancedConfiguration

Set-VMHostAdvancedConfiguration : 6/23/2011 12:10:19 PM    Set-VMHostAdvancedCo
nfiguration        A specified parameter was not correct.

At C:\Documents and Settings\jsmith\Desktop\PowerShell Scripts\NFS Defau
lt Changes.ps1:4 char:37
+      Set-VMHostAdvancedConfiguration <<<<  -VMHost $_ -Name Net.TcpIpHeapMax
-Value 120
    + CategoryInfo          : NotSpecified: (:) [Set-VMHostAdvancedConfigurati
   on], InvalidArgument
    + FullyQualifiedErrorId : Client20_MoServiceImpl_Invoke_ViError,VMware.Vim
   Automation.ViCore.Cmdlets.Commands.Host.SetVMHostAdvancedConfiguration

justinsmith
Enthusiast
Enthusiast

I actually found this script and its based on NFS best practices for NetApp (which is the storage I use) and made the changes for ESXi 4...

param

(

[parameter(Mandatory

= $true)]

[

string[]]$vCenter

)

Connect-VIServer

$vCenter

$esxHosts

= Get-Cluster Clustername | Get-VMHost | Sort Name

foreach

($esx in $esxHosts){

Write-Host "Updating TCP and NFS Advanced Configuration Settings on $esx"

# Update TCP Settings

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name Net.TcpipHeapSize).Values -ne "32"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name Net.TcpipHeapSize -Value 32 -Confirm:$false

}

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name Net.TcpipHeapMax).Values -ne "120"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name Net.TcpipHeapMax -Value 120 -Confirm:$false

}

# Update NFS Settings

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatMaxFailures).Values -ne "10"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatMaxFailures -Value 10 -Confirm:$false

}

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatFrequency).Values -ne "12"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatFrequency -Value 12 -Confirm:$false

}

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatTimeout).Values -ne "5"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.HeartbeatTimeout -Value 5 -Confirm:$false

}

if((Get-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.MaxVolumes).Values -ne "64"){

Set-VMHostAdvancedConfiguration -VMHost $esx -Name NFS.MaxVolumes -Value 64 -Confirm:$false

}

}

Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee

Ahh, they are case sensitive....

Get-Cluster Cluster1 | Get-VMHost | Foreach {
     Set-VMHostAdvancedConfiguration -VMHost $_ -Name NFS.MaxVolumes -Value 64
     Set-VMHostAdvancedConfiguration -VMHost $_ -Name Net.TcpipHeapSize -Value 32
     Set-VMHostAdvancedConfiguration -VMHost $_ -Name Net.TcpipHeapMax -Value 120
}

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos