Scheduling VMware’s FT (Fault Tolerance)

What is VMware Fault Tolerance (FT)? I’d start with reviewing the overview page.

VMware Fault Tolerance, based on vLockstep technology, provides zero downtime, zero data loss continuous availability for your applications, without the cost and complexity of traditional hardware or software clustering solutions.

Pretty awesome no? FT has it’s limits (1 vCPU, etc) and it has plenty of caveats to it’s use as well (all covered in the docs, linked from the over view page). Despite all of that, it has some extremely interesting use cases. Say, protecting that web server that absolutely cannot fail. Providing protection to that mission critical app, that runs on NT4, and was written in Cobol.

One of the other use cases that for FT that I find especially interesting, came from episode 53 of the VMTN podcast. Using the ability to selectively turn FT on and off again for a specific VM, you can provide protection to long running reports/jobs within your infrastructure. Say that accounting report that takes 3 days every month to run, now with FT, if host dies 2.5 days in, the VM will still be processing, uninterrupted on the other node.

On hearing that, I decided that, with a predictable workload like this, there is no reason it shouldn’t be scheduled. After all, clicking enable FT once a month is only cute the first time. How do we go about scheduling it? First you figure out how to enable FT using the PowerCLI (or have someone on Twitter point out the communities post it’s in 🙂

To enable FT for a VM:

Get-VM X | Get-View | % { $_.CreateSecondaryVM($null) }

This will choose a host, if you want to specify a specific host, pass the host’s MOR in place of $null. To disable, run:

Get-VM X | Select -First 1 | Get-View | % { $_.TurnOffFaultToleranceForVM() }

Note that in PowerCLI 4.0 Get-VM will return a fault tolerant VM twice, so we select the first one.

So now that we have that, now do we get it scheduled?

We do this this using a Credentials file, a PowerCLI script, Windows Task Scheduler, and some magic! Let’s get started:

1) The credentials file – This can be made using the instructions here.

2) Now to build the PowerCLI around it:

3) Using the great post from Virtu-al, we apply a little magic to Windows Task Scheduler using a command line similar to:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe “& ‘C:\Scripts\set-ft.ps1 VM1 on′”

So what did we just do? We have written a script to enable or disable FT, and shown you how to schedule it using Windows Task scheduler. We also covered a little bit as to why you might want to do this.

Awesome? I sure think so. Do you? Let us know in the comments.