# Deploy High Availability on version 5.12.x

**URL:** https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411
**Category:** Operations
**Created:** [April 19, 2021, 6:50am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411 "2021-04-19T06:50:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nhtuong](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/nhtuong/32/7217_2.png) [@nhtuong](https://forum.opennebula.io/u/nhtuong)
#### Post date: [April 19, 2021, 6:50am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/1 "2021-04-19T06:50:36Z")

</div>

Hi all,

I am deploying the HA for 3 nodes in my OpenNebula cluster and get the below error when I shutdown the **node1** :

- **/var/log/one/host\_error.log**

> [2021-04-17 23:20:29 +0700][HOST 9][I] Hook launched  
> [2021-04-17 23:20:29 +0700][HOST 9][I] hostname: node1  
> [2021-04-17 23:20:29 +0700][HOST 9][I] Wait 5 cycles.  
> [2021-04-17 23:20:29 +0700][HOST 9][I] Sleeping 120 seconds.  
> [2021-04-17 23:22:29 +0700][HOST 9][I] Fencing enabled  
> [2021-04-17 23:22:29 +0700][HOST 9][E] Fence ip not found  
> [2021-04-17 23:22:29 +0700][HOST 9][E]  
> [2021-04-17 23:22:29 +0700][HOST 9][E] Fencing error  
> [2021-04-17 23:22:29 +0700][HOST 9][E] Exiting due to previous error.

- **/usr/share/one/examples/host\_hooks/error\_hook**

> ARGUMENTS = “$TEMPLATE -m -p 5 -u”  
> COMMAND = “/var/lib/one/remotes/hooks/ft/host\_error.rb”  
> NAME = “host\_error”  
> STATE = “ERROR”  
> REMOTE = “no”  
> RESOURCE = HOST  
> TYPE = state

- **/var/lib/one/remotes/hooks/ft**

I’ve comment the line “echo ““Fence host not configured, please edit ft/fence\_host.sh”” && exit 1” and added the fence action to the last line:

> fence\_ilo -a $FENCE\_IP -l oneadmin -p -o

Can anyone tell me did I configure something wrong? I’ve searched on both OpenNebula site and the forum but there is no topic about how to configure the **FENCE\_IP**.  
Any help will be very appriciated.

Regards,

Tuong Nguyen

---

<div class="post-metadata">

### Author: ![feldsam](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/feldsam/32/4441_2.png) [@feldsam](https://forum.opennebula.io/u/feldsam)
#### Post date: [April 19, 2021, 6:37pm UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/2 "2021-04-19T18:37:52Z")

</div>

Hi, I use this script with FENCE\_IP on each host in template.

```auto
#!/bin/bash

# -------------------------------------------------------------------------- #
# Copyright 2002-2019, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #

##############################################################################
# WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
#
# This script needs to be modified to enable fencing of the host. By default it
# will fail, as the first line is 'exit 1'. You will need to remove it.
#
# In order to perform the fencing, you will probably need to install a fencing
# utility. They are typically found in: fence-agents-all (CentOS) and fence-
# agents (Ubuntu). They come with many utilities: fence_ilo, fence_ipmilan,
# fence_apc, etc...
#
# To call the fencing utility, you will need to pass some parameters, which are
# typically the iLO IP of the host, etc. We recommend you enter this information
# in the host's template, and pick it up using the xpath example below. AS AN
# EXAMPLE (only an example) the script below expects that you have defined a
# parameter called FENCE_IP in the Host's template, and it will rely on that to
# call the fencing mechanism. You should customize this to your needs. It is
# perfectly OK to discard the code below and use a different mechanism, like
# storing the information required to perform the fencing in a separate CMDB,
# etc. However, you will probably need to get the host's NAME, which should be
# done as shown below.
#
# WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
#############################################################################

# @param $1 the host information in base64
# @return 0 on success. Make sure this script does not return 0 if it fails.

#-------------------------------------------------------------------------------
# Get host parameters with XPATH
#-------------------------------------------------------------------------------

if [-z "$ONE_LOCATION"]; then
    XPATH=/var/lib/one/remotes/datastore/xpath.rb
else
    XPATH=$ONE_LOCATION/var/remotes/datastore/xpath.rb
fi

if [! -x "$XPATH"]; then
    echo "XPATH not found: $XPATH"
    exit 1
fi

XPATH="${XPATH} -b $1"

unset i j XPATH_ELEMENTS

while IFS= read -r -d '' element; do
    XPATH_ELEMENTS[i++]="$element"
done < <($XPATH /HOST/ID \
                    /HOST/NAME \
                    /HOST/TEMPLATE/FENCE_IP )

HOST_ID="${XPATH_ELEMENTS[j++]}"
NAME="${XPATH_ELEMENTS[j++]}"
FENCE_IP="${XPATH_ELEMENTS[j++]}"

echo "Host $HOST_ID $NAME: State Error!" | mail -s "$HOST_ID $NAME Error!" admin@feldhost.cz

#-------------------------------------------------------------------------------
# Fence
#-------------------------------------------------------------------------------

if [-z "$FENCE_IP"]; then
    echo "Fence ip not found"
    exit 1
fi

# Example:
# fence_ilo -a $FENCE_IP -l <username> -p <password>

```

---

<div class="post-metadata">

### Author: ![nhtuong](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/nhtuong/32/7217_2.png) [@nhtuong](https://forum.opennebula.io/u/nhtuong)
#### Post date: [April 20, 2021, 2:22am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/3 "2021-04-20T02:22:57Z")

</div>

Hi @feldsam ,

Thank you for your response.

Do you use this script on just Front-end? Because I can not find it in any KVM node.

And could you show me the steps you did to configure the HA after creating the host hook in **/usr/share/one/examples/host\_hooks/error\_hook**?

---

<div class="post-metadata">

### Author: ![feldsam](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/feldsam/32/4441_2.png) [@feldsam](https://forum.opennebula.io/u/feldsam)
#### Post date: [April 22, 2021, 8:13am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/4 "2021-04-22T08:13:28Z")

</div>

hello, yes, only on frontend. There is something more about HA setup problems

> [@Unable to set up HA for VM - ONE 6.0](https://forum.opennebula.io/t/unable-to-set-up-ha-for-vm-one-6-0/9428):
>
> Hello community! I am currently trying Open Nebula 6 and when setting up HA for VM I am running into some problems. I have added the hook by running onehook create \<my hook\>: ARGUMENTS = "$TEMPLATE -m -p 5" COMMAND = "/var/tmp/one/hooks/ft/host\_error.rb" Preformatted text`NAME = "host\_error" STATE = "ERROR" REMOTE = "no" RESOURCE = HOST TYPE = state When my host gives error I can see that the hook gets activated by reading /var/log/one/onehm.log Wed Apr 21 20:31:09 2021 …

---

<div class="post-metadata">

### Author: ![nhtuong](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/nhtuong/32/7217_2.png) [@nhtuong](https://forum.opennebula.io/u/nhtuong)
#### Post date: [April 23, 2021, 8:27am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/5 "2021-04-23T08:27:37Z")

</div>

Hi @feldsam ,

- I can setup the **FENCE\_IP** and the hook executed successfully.

- **/var/log/one/host\_error.log**

> [2021-04-23 14:42:25 +0700][HOST 9][I] Hook launched  
> [2021-04-23 14:42:25 +0700][HOST 9][I] hostname: node134  
> [2021-04-23 14:42:25 +0700][HOST 9][I] WARNING: Fencing disabled  
> [2021-04-23 14:42:25 +0700][HOST 9][I] states: 3, 5, 8  
> [2021-04-23 14:42:25 +0700][HOST 9][I] vms: [“30”, “28”]  
> [2021-04-23 14:42:25 +0700][HOST 9][I] resched 30  
> [2021-04-23 14:42:25 +0700][HOST 9][I] resched 28  
> [2021-04-23 14:42:25 +0700][HOST 9][I] Hook finished

- But it failed to migrate VM to the remaining hosts although I can migrate it manually without having any issue.

- **/var/log/one/sched.log**

> Fri Apr 23 15:25:49 2021 [Z0][VM][D]: Found 2 pending/rescheduling VMs.  
> Fri Apr 23 15:25:49 2021 [Z0][HOST][D]: Discovered 2 enabled hosts.  
> Fri Apr 23 15:25:49 2021 [Z0][VM][D]: VMs in VMGroups:  
> Fri Apr 23 15:25:49 2021 [Z0][VNET][D]: Discovered 0 vnets.  
> Fri Apr 23 15:25:49 2021 [Z0][SCHED][D]: Match-making results for VM 28:  
> Cannot schedule VM, there is no suitable host.  
> Fri Apr 23 15:25:49 2021 [Z0][SCHED][D]: Match-making results for VM 30:  
> Cannot schedule VM, there is no suitable host.  
> Fri Apr 23 15:25:50 2021 [Z0][SCHED][D]: Dispatching VMs to hosts:  
> VMID Priority Host System DS  
> --------------------------------------------------------------

Do you have any idea about this?

---

<div class="post-metadata">

### Author: ![feldsam](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/feldsam/32/4441_2.png) [@feldsam](https://forum.opennebula.io/u/feldsam)
#### Post date: [April 23, 2021, 9:11am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/6 "2021-04-23T09:11:07Z")

</div>

You can test and debug this by “VM Reschedule” function in opennebula. You need to have host in same cluster with sufficient resources to handle VM.

---

<div class="post-metadata">

### Author: ![nhtuong](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/nhtuong/32/7217_2.png) [@nhtuong](https://forum.opennebula.io/u/nhtuong)
#### Post date: [April 28, 2021, 10:50am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/7 "2021-04-28T10:50:50Z")

</div>

Hi @feldsam ,

Thanks for your help, I can use HA with a VM deployed using a whole new template.

But I can not use HA with the existed VMs. Is there anyway to change the placement host here?

- New VM by new template:

![opennebula_vm41](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/b/b9d61da3c83ae1276c7c17d16ee7b992b4161984.png)

- Existed VM:

![opennebula_vm4](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/b/bcfef206a7916552c1195802b8ca335d7d2816a1.png)

---

<div class="post-metadata">

### Author: ![feldsam](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/feldsam/32/4441_2.png) [@feldsam](https://forum.opennebula.io/u/feldsam)
#### Post date: [April 28, 2021, 11:02am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/8 "2021-04-28T11:02:32Z")

</div>

Hi, you can use `onevm update <vmid>` command and edit XML manually

[https://docs.opennebula.io/doc/5.12/cli/onevm.1.html](https://docs.opennebula.io/doc/5.12/cli/onevm.1.html)

---

<div class="post-metadata">

### Author: ![nhtuong](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/nhtuong/32/7217_2.png) [@nhtuong](https://forum.opennebula.io/u/nhtuong)
#### Post date: [May 10, 2021, 3:09am UTC](https://forum.opennebula.io/t/deploy-high-availability-on-version-5-12-x/9411/9 "2021-05-10T03:09:30Z")

</div>

Hi,

Really thanks for your help, I can deploy the HA for my server.
