Section 13.4. Managing Virtual Machines from the Command Line


13.4. Managing Virtual Machines from the Command Line

Some actions on your virtual machines need to be performed from the Service Console. To give you an example, one time the authors had a virtual machine get stuck during a power-up operation in Virtual Center and we couldn't power it down from the Virtual Center client or the ESX Server MUI. So, we had to perform a hard power off from the command line to stop the VM. To manage virtual machines from the Service Console, use the vmware-cmd command. There are also scripts available to perform actions like backing up and restoring virtual disk files. In this section, we'll cover the following:

  • Using vmware-cmd to manage virtual machines

  • Viewing performance data for virtual machines with esxtop

  • Adding new virtual blank disks and extending existing virtual disks

  • Performing backups and restores of virtual machine virtual disks

13.4.1. Using vmware-cmd to Manage Virtual Machines

The vmware-cmd command allows you to perform many different tasks related to virtual machines. Figure 13.33 shows the server operations that can be performed on the Service Console using vmware-cmd. As you can see from the list, you can register and unregister virtual machines and get/set resource variables.

Figure 13-33. A List of Server Operations that Can Be Performed with vmware-cmd


Figure 13.34 shows the VM operations that can be performed from the Service Console using the vmware-cmd utility.

Figure 13-34. A List of VM Operations that Can Be Performed with vmware-cmd


To display all registered VMs, type

vmware-cmd -l

Figure 13.35 displays the output from the command, which shows all the registered virtual machines on ESX Server.

Figure 13-35. Output from the vmware-cmd/ Command


To power on VMs from the Service Console, type

vmware-cmd vmx-configfile start soft

Figure 13.36 shows the syntax and output of the command.

Figure 13-36. Output from vmware-cmd to Perform the Power-Up Operation


To power off VMs from the Service Console, type

vmware-cmd vmx-configfile stop soft

or

vmware-cmd vmxfilename stop hard

13.4.2. Viewing Performance Data for Virtual Machines with esxtop

To view virtual machine performance data, type

esxtop

The output is shown in Figure 13.37 This allows you to view performance statistics for individual virtual machines as well as statistics for overall memory usage, swap file usage, and the disk and network performance of your ESX Server. The esxtop utility is similar to the top utility but is more specific for virtual machine performance data. To exit esxtop, press q to quit. As with the top utility, there are other options you can use to change the way the data is displayed within esxtop. Also, you can view the man pages for esxtop by typing man esxtop at the command line.

Figure 13-37. Displays the esxtop Utility Screen


To find out the virtual machine you're viewing performance statistics for, you need to obtain the VMID number from the MUI and match it with the WID number in esxtop.

13.4.3. Adding a New Virtual Disk, Blank Virtual Disk, and Extending Your Existing Virtual Disk

To create a new blank virtual disk, type

vmkfstoolsc size vmfs-name:vmdk-name

as in the following example:

vmkfstoolsc 2024m SanRaid1:data01.vmdk

What this allows you to do is add a new 2GB hard disk which can then be added to all existing virtual machines and formatted at the OS level within the VM.

To extend a virtual disk, type

vmkfstoolsX new-size vmfs-name:vmdk-name

An example of this is shown in the following:

vmkfstoolsX 12288m SanRaid1:database.vmdk

Note: The virtual machine needs to be powered off prior to extending the virtual disk. VMware recommends you make a full backup on the vmdk file prior to completing this task. You will also need to use a utility like Partition Magic to extend the partition within the VM for it to recognize the additional space added to the disk file.

13.4.4. Performing Backups and Restores of Virtual Machine Virtual Disks

You may want to incorporate the following scripts into your disaster recovery process for your virtual machines.

If you want to back up a virtual machine's virtual disk while it's still powered on, type

vmsnap.pla backup-serverc path-to-vm-config-file

You must replace the backup-server argument with the name of a server that's configured to receive the exported virtual disk over SCP.


Note: VMware recommends that you quiesce the application running within the virtual machine in order to get the most consistent backup. If you want to schedule your backups, you could also set up a cron job to run nightly.

You can also restore virtual machines backed up with this method by typing

vmres.pla backup-serverc path-to-vm-config-fileo ownerg groupv VMFS



Virtualization With VMware ESX Server
Configuring VMware ESX Server 2.5 (Vol 1)
ISBN: 1597490199
EAN: 2147483647
Year: 2005
Pages: 173

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net