Tag Archives: HA

PowerCLI: Reconfigure for vSphere HA

Sometimes when you change something to the vSphere HA configuration like an Advanced Option, you have to reconfigure vSphere HA on each host inside that particular cluster. You can do that by hand via the Reconfigure for vSphere HA.. option inside the vSphere (Web) Client:

Screenshot 2016-01-22 13.11.47

Or you can use the following PowerCLI one-liner to perform this step on every host inside that cluster.

Get-Cluster <clusterName | Get-VMhost | Sort Name | %{$_.ExtensionData.ReconfigureHostForDAS()}

Just change <clusterName> the to the name of the cluster en open PowerCLI, connect to the vCenter server and run the one-liner.

PowerCLI: Disable / Enable HA Host Monitoring

In the case you need to or your network team needs to do some network maintenance on the switches which VMware HA uses to communicate with the other hosts or where the das.isolationaddress (default gateway) is configured/ It’s smart to disable the Host Monitoring feature of VMware HA. You can do this easily by hand via edit cluster – VMware HA and uncheck the Enable Host Monitoring feature. See screenshot below:


But what if you have to disable Host Monitoring on multiple VMware HA cluster? Well, if you like PowerCLI, you can use the following script to disable or enable the HA Host Monitoring feature:


if($vCenter -eq $null){
    Write-Host "Please enter the name of the vCenter Server" -ForegroundColor Yellow

    enabled {"The HA Host Monitoring feature will be enabled"}
    disabled {"The HA Host Monitoring feature will be disabled"}
    default {"the option value could not be determined."

Connect-VIServer $vCenter

$clspec = New-Object VMware.Vim.ClusterConfigSpecEx
$clspec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
$clspec.dasConfig.hostMonitoring = $option

foreach($cluster in (Get-Cluster | sort Name)){
    $clview = Get-Cluster $cluster | Get-View
    $clview.ReconfigureComputeResource_Task($clspec, $true)

Disconnect-VIServer -Confirm:$false

Just save the script to change-HAHostMonitoring.ps1 and run it like this to disable the HA Host Monitoring feature:

Change-HAHostMonitoring vcenter.domain.loc disabled

If you want to enable Host Monitoring, just change disabled to enabled:

Change-HAHostMonitoring vcenter.domain.loc enabled

Note: Please test the script mentioned in this blog post in a lab or test environment before you use the script in a production environment.

PowerCLI: Document the ESX Hostname of the vCenter VM


I was reading Duncan Epping his post: http://www.yellow-bricks.com/2009/10/09/best-practices-running-vcenter-virtual-vsphere/ about Running vCenter virtual. The most of the steps described, you only have to do once but step 5 needs to be documented once in a while

5. Write a procedure to boot the vCenter / AD / DNS / SQL manually in case of a complete power outage occurs.

Nobody likes to document this thing so we will let PowerCLI do this job for us.

First you need to now the VMs. In most cases this will be your Domain Controller, Database Server and of course the vCenter VM.

$vms =  Get-VM "DC01", "DB01", "VC01" | Sort Name
$vms | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, `
@{N="VMHost";E={Get-VMHost -VM $_}} 

The one-liner above will return the VM name, Cluster Name and ESX Host name:


Now you are able to document where your VMs are. But you still need to put this information somewhere. So I created a simple script which will export the information displayed above to a CSV file. The script will also remove files older than 7 days.

You can change the variable if you want.

$now = Get-Date
$days = "7"
$targetFolder = "C:\vCenter"

if (Test-Path $targetFolder)
    Write-Host $targetFolder "Already exists"
    New-Item $targetFolder -type directory
    Write-Host $targetFolder "Created"

$lastWrite = $now.AddDays(-$days)
$files = get-childitem $targetFolder -include *.csv -recurse `
    | Where {$_.LastWriteTime -le "$lastWrite"} 

if (($files | Measure-Object).count -gt 0){
foreach ($file in $files)
{write-host "Deleting File $File" -foregroundcolor "Red"; `
    Remove-Item $file | out-null}

$filename = "C:\vCenter\" + (Get-Date -format  'yyyy-MM-dd hh-mm-ss') + '.csv'
$vms =  Get-VM "DC01", "DB01", "VC01" | Sort Name 
$vms | Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, `
@{N="VMHost";E={Get-VMHost -VM $_}} | `
Export-Csv -NoTypeInformation $filename

The script will generate a CSV file:


The CSV file will look like this:





You can schedule this script on a VM that runs on another cluster or maybe better, schedule the script on a physical box. If you want to know how to schedule a Powershell/CLI script, go check out this post from Alan Renouf: http://www.virtu-al.net/2009/07/10/running-a-powercli-scheduled-task/

Now you are able to track the most important VMs in your environment.

Enable HA on a mixed ESX Cluster


I have a mixed ESX cluster at home. One box is running ESX 3.5 the other box is running ESX 4.0. When I tried to enable HA on this cluster I got the following error:


The ESX 3.5 host has a second Service Console port on the Storage (iSCSI) lan. The ESX 4.0 host doesn’t need this so this is why the ESX 4.0 host got this error.

To solve this issue I created a second Service Console Port on my ESX4.0 server.


Now I was able to enable HA on Cluster.

ESX 3i: host in HA Cluster must have userworld swap enabled


After adding my first HP ML 110 ESX3i to my brand new HA cluster I got the following error:


The host who gives the error, did not have the ScratchConfig.ConfiguredSwapState option enabled.


This is how you enable this option:

1. In VirtualCenter, select the ESX 3i server with the error.
2. Click the "Configuration" tab page and click "Advanced Settings"
3. Select "ScratchConfig"
4. Set the data store for ScratchConfig.ConfiguredScratchLocation to a valid directory with more than 1GB to hold the swapfile. This location can be local or shared storage.
5. Select the ScratchConfig.ConfiguredSwapState option.
6. Click OK.
7. reboot the 3i server to apply the changes.

Source: http://www.virtualvcp.com/content/view/33/43/

VMware KB: KB1004177

VMware: ESX 3.5 Update 3 VM’s spontaneously reboot

Verschillende blogs melden deze bug al eerder. Bij deze plaats ik ook nog even een post.

Ivo schrijft het volgende op zijn blog: http://www.ivobeerens.nl

We disabled in HA the option “Virtual Machine Monitoring” and set DRS to manual.  The problem with Virtual Machine monitoring is:

The Virtual Machine heartbeats are being dropped which is triggered by VMotion and the VM gets reset by the HA feature as it thinks it has gone offline. Since the feature is now off it should be safe to turn on DRS again.

There are more people who have this problem, read the following post on the VMware forum, 3.5U3 – any guinea pigs yet?.

I made a support request @ VMware. The told me today that 20 November patch 10 for VMware 3.5 Update 3 will be released. Patch 10 fixes SOME random reboot problems in Update 3. I hope it resolves this nasty issue.


Bron: http://www.ivobeerens.nl/?p=180