Lab Virtual Machines: Difference between revisions
(added instructions for restoring from backup) |
|||
Line 19: | Line 19: | ||
If you ever need to restore from these backups: | If you ever need to restore from these backups: | ||
1. scp /export/ex9/archive/libvirt/images/20180817-he-VM_images.tar & /export/ex9/archive/libvirt/xml/he_VM_xml.tar.gz back to he or any functioning hypervisor. | 1. scp /export/ex9/archive/libvirt/images/20180817-he-VM_images.tar & /export/ex9/archive/libvirt/xml/he_VM_xml.tar.gz back to he or any functioning hypervisor. <br /> | ||
2. Untar the contents somewhere safe. Don't untar in /var/lib/libvirt or /etc/libvirt/qemu. Tar defaults to overwrite existing files. | 2. Untar the contents somewhere safe. Don't untar in /var/lib/libvirt or /etc/libvirt/qemu. Tar defaults to overwrite existing files. <br /> | ||
3. images .tar captures the /var/lib/libvirt directory. Move everything below that directory to /var/lib/libvirt or copy the necessary contents to /var/lib/libvirt. For default hypervisor installations, images are stored in /var/lib/libvirt/images. | 3. images .tar captures the /var/lib/libvirt directory. Move everything below that directory to /var/lib/libvirt or copy the necessary contents to /var/lib/libvirt. For default hypervisor installations, images are stored in /var/lib/libvirt/images. <br /> | ||
4. For situations where you need VMs redeclared, you must move the .xml files from he_VM_xml.tar.gz to /etc/libvirt/qemu/. Define VMs with the command: | 4. For situations where you need VMs redeclared, you must move the .xml files from he_VM_xml.tar.gz to /etc/libvirt/qemu/. Define VMs with the command: | ||
virsh define <location of VM.xml file> | virsh define <location of VM.xml file> | ||
Line 41: | Line 41: | ||
5. If a VM is properly defined, you only need to do the following command to start the VM: | 5. If a VM is properly defined, you only need to do the following command to start the VM: | ||
virsh start <VM_Name> | virsh start <VM_Name> | ||
==Cluster 0== | ==Cluster 0== |
Latest revision as of 17:29, 21 August 2018
There are important VMs on both Cluster 0 and Cluster 2. Cluster 0 uses VMware while Cluster 2 uses KVM/libvirt.
Virtual Machine Backups
he is the main hypervisor of BKS. It holds the following VMs:
alpha DNS,DHCP,Puppet,Foreman beta Authentication server; openldap chi ??? epsilon public portal gateway to cluster gamma Sun Grid Engine phi for excipients website psi pgf fortran compiler tau web server for zinc zeta psicquic server sigma not sure what this does but we can keep it off
omega matt o'meara. transportal. These VMs were backed up to qof:/export/ex9/archive/libvirt during the downtime of Aug 17,2018. The file format is a .tar.gz file.
If you ever need to restore from these backups:
1. scp /export/ex9/archive/libvirt/images/20180817-he-VM_images.tar & /export/ex9/archive/libvirt/xml/he_VM_xml.tar.gz back to he or any functioning hypervisor.
2. Untar the contents somewhere safe. Don't untar in /var/lib/libvirt or /etc/libvirt/qemu. Tar defaults to overwrite existing files.
3. images .tar captures the /var/lib/libvirt directory. Move everything below that directory to /var/lib/libvirt or copy the necessary contents to /var/lib/libvirt. For default hypervisor installations, images are stored in /var/lib/libvirt/images.
4. For situations where you need VMs redeclared, you must move the .xml files from he_VM_xml.tar.gz to /etc/libvirt/qemu/. Define VMs with the command:
virsh define <location of VM.xml file>
This will only work if the XML file has a line that points to the proper VM image location in /var/lib/libvirt/images. Make sure the XML file points to the corresponding location. For example, for the VM alpha, the xml file states the following lines:
<disk type='file' device='disk'> <driver name='qemu' type='qcow2'/> <source file='/var/lib/libvirt/images/bulk/alpha-root'/> <target dev='vda' bus='virtio'/> <alias name='virtio-disk0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </disk> <disk type='file' device='disk'> <driver name='qemu' type='qed'/> <source file='/var/lib/libvirt/images/bulk/alpha-share'/> <target dev='vdb' bus='virtio'/> <alias name='virtio-disk1'/>
In this situation, you must have the proper VM images in those locations. The he-VM_images.tar will have these images in the proper location.
5. If a VM is properly defined, you only need to do the following command to start the VM:
virsh start <VM_Name>
Cluster 0
Significant hypervisors on Cluster 0: vmware1 (access via root with clust 0 formulax2)
VMWare Commands
Webpage that describes numerous VMware commands: http://www.doublecloud.org/2013/11/vmware-esxi-vim-cmd-command-a-quick-tutorial/
# To get a list of all VMs and obtain VMid vim-cmd vmsvc/getallvms
# To shutdown a VM: vim-cmd vmsvc/power.off <VMid>
# To turn on a VM: vim-cmd vmsvc/power.on <VMid>
Cluster 2
kvm/libvirt commands
In order for a user to issue KVM commands, the service libvirtd must be running. Check the status of libvirtd by issuing the command: service libvirtd status. If libvirtd is not running, then you may issue command: service libvirtd start.
# to get list of VMs on hypervisor virsh list --all
# to start a VM virsh start <VM-name or VMid>
# to shutdown a VM virsh shutdown <VM-name or VMid>
# to force shutdown a VM (equivalent of pulling the plug on a computer) virsh destroy --graceful <VM-name or VMid>
# to pause a VM virsh suspend <VM-name or VMid>
# to unpause a VM virsh resume <VM-name or VMid>
# get XML file contents of VM virsh dumpxml <VM-name or VMid>