[PVE-User] HA migration behaviour vs. failures

Adam Thompson athompso at athompso.net
Tue Jul 29 18:06:04 CEST 2014


On 14-07-29 10:34 AM, Joel S. | VOZELIA wrote:
> Would you mind sharing that HA control script /usr/local/bin/bascule_rhcluster.pl?
Yes, please.

This is the very simplistic script I wrote for my own use:

===begin /root/evacuate.sh===
#!/bin/bash
# no sense in re-invoking this, it isn't likely to change while we're 
running
H=$(hostname)
# magically declare arrays with () syntax
OTHERNODES=($(pvesh ls /nodes | awk '$NF !~/'$H'/ {print $NF}'))
VMS=($(pvesh ls /nodes/$H/qemu | awk '{print $NF}'))
# Naïve round-robin distribution, not weighted.
i=0
for V in ${VMS[@]}; do
   i=$(($i + 1))
   pvesh create /nodes/$H/qemu/$V/migrate -target ${OTHERNODES[$(( $i % 
${#OTHERNODES[@]} ))]} -force -online
   printf '\n'
done
===end===

Not wonderful by any stretch, but it makes my life easier when it's time 
to apply updates or do system maintenance.  If only I could run multiple 
migrations in parallel...
All the complicated-looking substitution in third-last-line is doing is 
iterating through $OTHERNODES[] in an evenly-distributed manner. Since I 
have 4 identical nodes in the cluster, with more than enough spare 
capacity, that approach works for me.

-- 
-Adam Thompson
  athompso at athompso.net




More information about the pve-user mailing list