phillbl
Enthusiast
Enthusiast

shut down multiple vm servers

Jump to solution

Hi,

we have a power down this weekend & was wondering if it were possible to power all the vm servers down gracefully all at once. we have found that you can do a shut down -h on the host & are thinking of using this method. Anyone tried this or suggest a better way? i dont really want to have to log on to each vm or use the shut down using VI client. Is scriping an option?

thanks

phill

0 Kudos
1 Solution

Accepted Solutions
ShouldEye
Enthusiast
Enthusiast

Just to correct a small error/typo. The code should read:

VMLIST=`vmware-cmd -l`

for config in $

do

vmware-cmd $config stop trysoft

done

vimsh -n -e /hostsvc/maintenance_mode_enter

shutdown -h now

View solution in original post

0 Kudos
6 Replies
ShouldEye
Enthusiast
Enthusiast

You can write a script that executes the following (On every ESX server):

To get a list of all VM's on ESX host

vmware-cmd -l

To shutdown the VM's gracefully:

vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx stop trysoft

To test if all VM's are off:

vmware-cmd vmfs/volume/vmfslabel/VMName/VMName.vmx getstate

phillbl
Enthusiast
Enthusiast

so is shut down -h not a good idea then?

0 Kudos
ShouldEye
Enthusiast
Enthusiast

shutdown -h (or init 0) will shutdown the ESX host. You need to gracefully bring down all the VM's running on the ESX host first. After testing that all the VM's are down you can execute shutdown -h. It is however recommended that you place and ESX server in maintenance mode (also possible from console AFAIK) before you do a shutdown.

If you write a script you can basically cleanly bring down the enite server and ESX host by executing one command.

ShouldEye
Enthusiast
Enthusiast

.

depping
Leadership
Leadership

No it's definitely not a good idea to shutdown the host without

shutting down the vjm's first. it's like pulling a powercord out of

your system, it could lead to corrupt databases, filesystems etc. I

would recommend the following script to shut all vm's down, put the

host in maintenance mode and shutdown the host:

VMLIST=’vmware-cmd -l’
for config in $
do
vmware-cmd $
stop trysoft
done
vimsh -n -e /hostsvc/maintenance_mode_enter
shutdown -h now

Duncan

Blogging: http://www.yellow-bricks.com

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
ShouldEye
Enthusiast
Enthusiast

Just to correct a small error/typo. The code should read:

VMLIST=`vmware-cmd -l`

for config in $

do

vmware-cmd $config stop trysoft

done

vimsh -n -e /hostsvc/maintenance_mode_enter

shutdown -h now

0 Kudos