PVE Cluster Node Maintenance Mode?

cloudguy

Renowned Member
Jan 4, 2012
44
0
71
HI Everyone,

Is there a way to invoke maintenance mode on a Proxmox cluster node? I'm looking for the semi-automated functionality of Proxmox being able to:

1. Live Migrate all running machines on a node;
2. Place this node into maintenance mode such that no new VMs can be started on that node until the status is cleared/lifted.

Same as vSphere.

Is this possible today?
 
+1 for live migrate all running machines to another node

...our "workaround" for now ;-)

Code:
#!/bin/bash
if [ -z $1 ] ; then
 echo "usage: $0 <target-node> [offline]"
 echo "       Migrate all CTs and VMs on local node to target node."
 echo "       Online- (Live-)migration is default."
 echo "       In case live migration fails, please try offline mode."
 exit
fi

if [ ! -d /etc/pve/nodes/$1 ] ; then
 echo "Target node $1 does not exist!"
 exit 1
fi

ping -c 2 -W 2 $1 >/dev/null 2>&1
if [ $? != 0 ] ; then
 echo "node $1 is not reachable."
 exit 1
fi

if [ "x$2" == "xoffline" ] ; then
 OPT=""
else
 OPT="-online"
fi

CFG="/etc/pve/local/"

FILES1=$(find $CFG/openvz -maxdepth 1 -name "*.conf")
FILES2=$(find $CFG/qemu-server -maxdepth 1 -name "*.conf")
FILES="$FILES1 $FILES2"
for VE in $FILES ; do
 V=`basename $VE`
 VEID=`echo $V|cut -f1 -d\.`
 TYPE="OVZ"
 CMD="pvectl"
 if [ `expr match $VE ".*/qemu-server/.*"` -ne 0 ] ; then
  TYPE="KVM"
  CMD="qm"
 fi
 echo "migrating $TYPE: $VEID to $1..."
 $CMD migrate $VEID $1 $OPT
 echo "$VEID done."
done
 
May I suggest using this version of the script instead?

Changes: Only migrate running CT's and VM's

Code:
#!/bin/bash
if [ -z $1 ] ; then
 echo "usage: $0 <target-node> [offline]"
 echo "       Migrate all running CTs and VMs on local node to target node."
 echo "       Online- (Live-)migration is default."
 echo "       In case live migration fails, please try offline mode."
 exit
fi


if [ ! -d /etc/pve/nodes/$1 ] ; then
 echo "Target node $1 does not exist!"
 exit 1
fi


ping -c 2 -W 2 $1 >/dev/null 2>&1
if [ $? != 0 ] ; then
 echo "node $1 is not reachable."
 exit 1
fi


if [ "x$2" == "xoffline" ] ; then
 OPT=""
else
 OPT="-online"
fi


for OVZ in $(pvectl list|grep running|awk '{print $1}'); do
  echo "Migrating OVZ: $OVZ to $1..."
  pvectl migrate $OVZ $1 $OPT
  echo "$OVZ done."
done


for KVM in $(qm list|grep running|awk '{print $1}'); do
  echo "Migrating KVM: $KVM to $1..."
  qm migrate $KVM $1 $OPT
  echo "$KVM done."
done
 
  • Like
Reactions: Larryl
doesnt HA automatically move all the VMs back onto the node youre emptying if you were to use something like that?
 
HA could restart those machine elsewhere (AFAIK random node) after they are shut down because their node is shut down. Not live migrated.

Marco
 
Hi,

Right, I'm not at work right now but I patched this kind of script to migrate HA managed VMs 'runnig. Stopped ones did not migrate).

Thanks,

Christophe.
 
https://github.com/cvk98/Proxmox-host-maintenance-mode

This script allows you to prepare the Proxmox host for maintenance. After the launch, you are prompted to select a host. Next, checks are carried out for the availability of free cluster resources, the presence of containers (lxc), as they are rebooted during migration. It also checks the availability of local resources for the VM, because they do not allow the VM to migrate. If all the checks are passed, the migration begins. The result should be a completely free host.
 
  • Like
Reactions: UdoB

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!