Proxmox HA - turning off mashine when one node is down

krzysiexp

New Member
Apr 3, 2018
8
1
3
31
Hi!
I have 4 nodes Proxmox cluster.
VM on that nodes are HA managed:
  • node1: 2x prod VM
  • node2: 1x prod VM
  • node3: 1x prod VM
  • node4: 1x test VM
I want to turn off the test VM when any of nodes is down to free resources for production VM's.
Is there any way to configure this?
 
no, you would have to script that yourself, e.g. with a cronjob/systemd timer check how many nodes are online and set the wanted ha state for that vm
 
  • Like
Reactions: krzysiexp
Thanks for reply
Is there any better command to check how many nodes are online than "ha-manager status"?
 
there are multiple possibilities, e.g.

Code:
pvecm status
pvecm nodes
pvesh get /cluster/config/nodes
 
Hi,

I want to turn off the test VM when any of nodes is down to free resources for production VM's.
Is there any way to configure this?


You can make a custom script, who can count the online nodes(pvecm status | grep ...| wc ....). So IF online nodes < 4 THEN "shut down VM_with_id_XXXX". You will need to run this script on at least 2 nodes or more(in case of the node who run this script is down). The best way is to run this script on the node who run your "test VM"(=node4).

Good luck!
 
Thanks for help
I wrote a simple script

#!/bin/bash
VM_ID_TO_STOP=300
if [[ $(pvecm status | grep Nodes | tr -dc '0-9') -lt 4 ]] && [[ qm status ${VM_ID_TO_STOP} | grep -o '\S*$' == "running" ]]; then
echo 'Less than 4 nodes in cluser - shuting down VM ${VM_ID_TO_STOP}' | systemd-cat -t "vm-shutdown-script" -p emerg
qm stop ${VM_ID_TO_STOP}
fi


And it works :)
 
  • Like
Reactions: guletz