Solved

Schedule Shutdown and Restart CVM

  • 16 August 2022
  • 3 replies
  • 2988 views

Hi everyone, i have a question that can we schedule shutdown and restart CVMs, AHV host automatically? For example, I want to shutdown system at 9 P.M and restart it at 9 A.M. It could be scripts or anything else. Hope your helps 

icon

Best answer by Ken.Moellman 17 August 2022, 18:25

View original

This topic has been closed for comments

3 replies

Userlevel 1
Badge +1

Hello, if done correctly, this is a task with many steps.
1. shut down all virtual machines

for vm_name in `acli vm.list power_state=on | grep -v ^'VM name' | awk '{print $1}'`; do acli vm.shutdown $vm_name; done


2. stop the cluster

cluster stop


3. turn off the cvm

cvm_shutdown -P now


4. turn off ahv with the server

shutdown -h

 

For start

5. run in the reverse order, except for cvm and ahv, it will start itself.

 

But

You can go in a brutal and wrong way, put a timer on the power socket, in 99% of cases the cluster and virtual machines experience this method normally. This method is only suitable for your test infrastructure. For the normal functioning of the services, it is not advisable to turn off and turn on the platform.

Hi, Alexander Kharitonov

I tried your given steps before and it ran smoothly but my expectation is that to schedule automatically these steps without log in CVM → AHV anymore. Hope to see your answer.

Thank you so much!

Userlevel 2
Badge +2

As Alexander noted above, these are the likely steps.  You will have to interact with the cluster in some way; at a minimum to start the cluster back up.  

To add to what was said, the “start” process will require some work and proper hardware if you want to automate it.  You will need to be able to log into the IPMI/iLO/iDRAC type interface and power-on the server.  I would write a script that would run from an external server.

 

Shutdown would look like this:

  1. Get list of running VMs, store in a file on the local machine where the script is running
  2. Use list of running VMs to shutdown VMs
  3. Wait for all VMs to shut down
  4. Log into CVM
  5. Get list of all CVMs, hypervisors, and IPMI using “ncli host list” and store each list in a file (CVM file, Hypervisor file, IPMI file)
  6. Shut down cluster with “cluster stop” on CVM
  7. Wait for cluster to stop
  8. Log out of CVM
  9. Using the file with the CVM list, loop through the list of CVMs to connect to each one and shut the CVM down with “cvm_shutdown -P now
  10. Using the file with the hypervisor list, loop through the list of hypervisor servers to connect to each one and shutdown each hypervisor with “shutdown -h” (can also try “poweroff”)
  11. If your particular hardware doesn’t power off with this command, use the IPMI file to connect to each IPMI/iLO/iDRAC to power off the machine.


Power-on would probably look like this:

  1. Use a list of servers to connect to each IPMI/iDRAC/iLO and power-on the hardware
  2. Wait until the server is booted and the CVM is up and running on all servers. (ping, ssh checks, etc). You will likely need to connect to each hypervisor via SSH and then verify the status of the CVM. 
  3. Connect to CVM and issue “cluster start”
  4. Wait until cluster is fully up and running (likely with “cluster status”)
  5. Start up VMs from the Running VMs file you created at the very beginning. 

 

And then you would want to schedule cron or other task management to control this process timing.