unix:virtualization:techniques
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
| — | unix:virtualization:techniques [2022/05/08 17:52] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Tricks and Techniques ====== | ||
| + | Following are just some notes on how to "do things" | ||
| + | |||
| + | ===== Migration ===== | ||
| + | |||
| + | One nice thing about some hypervisors it the ability to move a virtual machine (vm) from one physical machine to another. There are two main ways to do this, shutting down the running vm, or doing it while the vm is still running. | ||
| + | |||
| + | In the following sections, //source// is the hypervisor moving from, //target// is the hypervisor being moved to, and ' | ||
| + | |||
| + | |||
| + | ==== Shutting Down and moving ==== | ||
| + | |||
| + | This method has the least limitations, | ||
| + | |||
| + | - Copy the vm configuration from //source// to //target// | ||
| + | - Modify the configuration on //target// | ||
| + | - If network bridges are different, either create the network bridge on the target, or change configuration on the //target// | ||
| + | - Perform any additional changes to the configuration file to adapt to //target// hypervisor. **Note** if source and target use different hypervisors and/or managers, this may require a complete rewrite of the configuration on //target// | ||
| + | - Shut down the vm on //source// | ||
| + | - Move all block devices to //target//. | ||
| + | - If iSCSI, NFS, or some other network shared storage, this may be as simple as mounting on //target//, and can be done before shutting down vm. | ||
| + | - If this is a physical partition, | ||
| + | - Bring the vm up on //target// | ||
| + | |||
| + | ==== Live Migration ==== | ||
| + | |||
| + | Live Migration rapidly migrates a running vm from source to target, in many cases with no downtime detectable by the end user. | ||
| + | |||
| + | This generally has some limitations imposed. For example, migrating a running Xen machine must have Xen on both //source// and //target//, and the version of Xen must be very close on both machines. Same with KVM and virtlib. The CPU's on both machines should be similar also. | ||
| + | |||
| + | But, if you have compatible systems, you can migrate machines with little or no impact on end users, either as precursor to maintenance, | ||
| + | |||
| + | === Limitations === | ||
| + | |||
| + | * Both hypervisors must be running compatible hypervisors. | ||
| + | * Should be same hypervisor family (xen, kvm, or a manager like virtlib that knows both) | ||
| + | * Hypervisor versions should be the same, though this will generally work within major versions, ie v7.1 and v7.5 should be able to work together. | ||
| + | * Block devices should be on shared storage. | ||
| + | * Usually uses iSCSI or a file on an NFS share | ||
| + | * Paths to block devices on //source// and //target// must be exact | ||
| + | * //source// and //target// should never use block devices simultaneously. | ||
| + | * //source// should shut down vm, first, freeing up block device, | ||
| + | * //target// may now bring up block devices | ||
| + | * Network definitions used by vm configuration must be accessible with same name on both //source// and //target//. | ||
| + | * //source// and //target// should be on same subnet | ||
| + | * //source// root user must have ssh access to //target// | ||
| + | * It is preferred if // | ||
| + | |||
| + | === Procedure === | ||
| + | |||
| + | - Ensure root access from //source// to //target// (required for Xen, preferred for all others) | ||
| + | - **Xen** <code bash>ssh target ' | ||
| + | - **virtlib** issue the command <code bash> | ||
| + | - Verify compatibility | ||
| + | - Ensure hypervisor compatibility between //source// and //target// | ||
| + | - Ensure network bridges with same name on //source// and //target// | ||
| + | - Ensure path to block devices same on //source// and //target// | ||
| + | - Issue command for migration from //source//. **Note** you can use the running virtual number instead of it's actual name in many cases | ||
| + | - **Xen** - <code bash>xl migrate vm targetmachine</ | ||
| + | - **KVM** - unknown | ||
| + | - **virtlib** - <code bash> | ||
| + | |||
| + | |||
| + | ===== Move VirtualBox images to KVM/Xen ===== | ||
| + | |||
| + | Oracle VirtualBox uses their own format for the disk back end. In order to move the block device from VirtualBox to something something else, the image needs to be converted to a //raw// format, then optionally converted to a //qcow2// format to conserve disk space. **Note:** in each case below, the commands need to be executed from a machine which has the virtualization tool installed. VBoxManage is only available on a VirtualBox machine, and qemu-img is only available on a machine which uses it, ie something that has had virt-manager, | ||
| + | |||
| + | Also, note that neither of these commands modify the original disk image. They convert the image, copying the converted file to a new one. | ||
| + | |||
| + | The following code will take VirtualBox' | ||
| + | |||
| + | <code bash> | ||
| + | VBoxManage clonehd / | ||
| + | </ | ||
| + | |||
| + | Virt-Manager can work with qcow2 formatted disk images, which are similar to VirtualBox' | ||
| + | |||
| + | <code bash> | ||
| + | qemu-img convert -f raw / | ||
| + | </ | ||
| + | |||
| + | You can now delete the original and intermediate files when you feel confident the process has gone well | ||
| + | |||
| + | ===== Sticky IP's (Reservations) with virt-manager ===== | ||
| + | |||
| + | virt-manager defaults to NAT on the networking. I find this useful on my laptop, where I don't always have a DHCP server available and the running virtuals should be private to my laptop. However, the dhcp server will occasionally give a different IP to the same machine. | ||
| + | |||
| + | To get around this, find the MAC address of the virtual, then set the network to always give it the same IP address. By default, the dhcp server built into virt-manager sets up an entire /24 range except for the primary IP, so we'll need to adjust that range also. | ||
| + | |||
| + | First, find the MAC address of the virtual you want to set up this way, and get the network list (usually " | ||
| + | <code bash> | ||
| + | # get network name | ||
| + | virsh net-list | ||
| + | # get MAC address of a virtual' | ||
| + | virsh dumpxml | ||
| + | </ | ||
| + | |||
| + | Now, edit the DHCP server | ||
| + | <code bash> | ||
| + | # change default to whatever you got in net-list, if it is different | ||
| + | virsh net-edit default | ||
| + | </ | ||
| + | |||
| + | Look through this list and find the XML block which defines the DHCP server. Adjust the range for automatic assignments to give you room to add your reservations, | ||
| + | |||
| + | <code xml> | ||
| + | < | ||
| + | <range start=' | ||
| + | <host mac=' | ||
| + | <host mac=' | ||
| + | <host mac=' | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Save your work, then you need to do something to get it all to begin work. [[https:// | ||
| + | |||
| + | ===== Links ===== | ||
| + | * [[https:// | ||
| + | * https:// | ||
unix/virtualization/techniques.txt · Last modified: by 127.0.0.1
