VM HA
The goal of this section is to provide information to prepare for failures of the Virtual Machines or Hosts and to recover from them. These failures are categorized depending on whether they come from the physical infrastructure (Host failures) or from the virtualized infrastructure (VM crashes). In both scenarios, OpenNebula provides a cost-effective failover solution to minimize downtime from server and OS failures.
Host Failures
When OpenNebula detects that a Host is down, a hook can be triggered to deal with the situation. OpenNebula comes out-of-the-box with a script that can act as a hook to be triggered when a Host enters the ERROR state. This can very useful to limit the downtime of a service due to a hardware failure, since it can redeploy the VMs on another Host.
/var/lib/one/remotes/hooks/ft/fence_host.sh is missing or fails, the hook exits without recovering or rescheduling any VMs. Configure the script as described in Enabling Fencing before using the hook. To explicitly skip fencing, add --no-fencing to the hook’s ARGUMENTS; a missing script does not disable fencing. Disabling fencing risks a split-brain condition, with the same VM running on multiple Hosts, potentially corrupting shared data.To set up this Host hook to be triggered in the ERROR state, you need to create it using the following template and command:
cat /usr/share/one/examples/host_hooks/error_hook
ARGUMENTS = "$TEMPLATE -m -p 5"
ARGUMENTS_STDIN = "yes"
COMMAND = "ft/host_error.rb"
NAME = "host_error"
STATE = "ERROR"
REMOTE = "no"
RESOURCE = HOST
TYPE = state
onehook create /usr/share/one/examples/host_hooks/error_hook
We are defining a Host hook, named host_error, that will execute the script ft/host_error.rb locally with the following arguments:
| Argument | Description | Default |
|---|---|---|
$TEMPLATE | Template of the HOST which triggered the hook. In XML format, base64 encoded | NA |
| Action | This defines the action to be performed upon the VMs that were running in the Host that went down. This can be: - -m migrate VMs to another Host. Only for images on shared storage (NFS, Ceph, …): This option skips VMs deployed on local datastores, so they can be started after Host recovery. - -r delete and recreate VMs running in the Host. Their state will be lost!- -d delete VMs running in the Host | NA |
| Force Inactive | -f force resubmission of VMs in SUSPEND and POWEROFF states | False |
| Avoid Transient | -p <n> avoid resubmission if Host comes back after <n> monitoring cycles | 2 |
| Avoid Fencing | --no-fencing avoid Host fencing | False |
More information on hooks here.
fence_host.sh to ensure the original VMs can no longer run before recovery proceeds.Manual VM Recovery and Split-Brain Prevention
When a Host enters the ERROR state due to a monitoring failure, its VMs may transition to the UNKNOWN state. However, this does not necessarily mean that the Host has failed or that the VMs have stopped running on the original hypervisor.
OpenNebula allows administrators to manually migrate or reschedule VMs in the UNKNOWN state to facilitate recovery from Host failures. Unlike recovery through the Host error hook, these manual operations do not automatically invoke the configured Host fencing mechanism.
Manually migrating or rescheduling VMs in the UNKNOWN state without ensuring that the original instances have stopped can lead to split-brain and severe data corruption.
This is particularly dangerous when using shared storage backends, such as Ceph, shared LVM (fs_lvm*), or the shared transfer driver (e.g., NFS), where multiple Hosts may access the same writable VM disks.
Before initiating manual recovery, administrators must ensure that the original VM instances are no longer running. This can be achieved through proper Host fencing or another reliable mechanism that prevents concurrent access to the same VM disks.
The ERROR Host state or UNKNOWN VM state alone does not guarantee that the original VM instances have stopped.
Administrators should also be aware that a Host may enter the ERROR state after a rescheduling request has been submitted but before the scheduler processes it. Therefore, the safety of a recovery operation must not be assumed solely based on the Host or VM state when the operation was initially requested.
For automated recovery, configure the Host error hook with proper fencing as described in Enabling Fencing.
Tuning HA responsiveness
This HA mechanism is based on the Host state monitoring. How long the Host takes to be reported in ERROR is crucial for how quickly you want the VMs to be available.
There are multiple timers that you can adjust on /etc/one/monitord.conf to adjust this. BEACON_HOST dictates how often the Host is checked to make sure it is responding. If it doesn’t respond past MONITORING_INTERVAL_HOST then the Front-end will attempt to restart the monitoring on the Host.
This process tries to connect to the Host via SSH, synchronize the probes, and start their execution. It might be possible that this SSH connection hangs if the Host is not responsive. This can lead to a situation where the VM workloads running on said Host will be unavailable and the HA will not be present during this process. You can adjust how much are you comfortable with waiting for this SSH to fail by setting the parameter ConnectTimeout on the oneadmin SSH configuration at /var/lib/one/.ssh/config.
The following is an example configuration
Host *
ServerAliveInterval 10
ControlMaster no
ControlPersist 70s
ControlPath /run/one/ssh-socks/ctl-M-%C.sock
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ConnectTimeout 15
Enabling Fencing
Fencing prevents VMs from continuing to run on an unresponsive Host before they are recovered on another Host. The Host error hook requires successful fencing by default. To configure it, duplicate /var/lib/one/remotes/hooks/ft/fence_host.sh from the shipped example:
cp -p /var/lib/one/remotes/hooks/ft/fence_host.sh.example \
/var/lib/one/remotes/hooks/ft/fence_host.sh
If the script is missing or returns an error, the hook stops without performing any VM recovery actions. Fencing is skipped only when --no-fencing is explicitly included in the hook’s ARGUMENTS, for example ARGUMENTS = "$TEMPLATE -m -p 5 --no-fencing". Use this option only when you can ensure that the VMs on the failed Host are no longer running before recovery proceeds.
The fence_host.sh file is yours and is preserved across OpenNebula upgrades, while the example may be updated by them. Adapt it to your infrastructure:
- Update your Hosts using
onehost update <HOST_ID>and add there the attributeFENCE_IPwith the fencing device IP. - Update the script and add
USERNAMEandPASSWORDof your fencing device. - Depending on your hardware provider, you will need to use a different tool to control the ILO, so please check your hardware manual, for example:
while [ "$RETRIES" -gt 0 ]
do
fence_ilo5 -P --ip=$FENCE_IP --password="${PASSWORD}" --username="${USERNAME}" --action="${ACTION}" && exit 0
RETRIES=$((RETRIES-1))
sleep $SLEEP_TIME
done
Continue with Troubleshooting guide to understand how to recover failed VMs.
GIVE FEEDBACK
Was this resource helpful?
Glad to hear it
Sorry to hear that