rookie play Cloud computing 16: RHEL6.4 virtual machine created on Ubuntu14.04 migrated to RHEL6.4 host
RHEL6.4 server as host for the virtual machine, perform the following commands to check the configuration and install the relevant software:
# egrep ' ^flags.* (VMX|SVM) '/proc/cpuinfo has display instructions for CPU support VT function 2, virtual Technolege (VT, virtualization Technology) to turn on CPU in motherboard BIOS 3, install kvm# yum Install KVM virt-* libvirt4, check if the KVM module is installed: # Lsmod | grep KVM displays similar to the following: Kvm_intel 53484 9kvm 316506 1 kvm_intel5, start service # services LIBVIRTD start
QEMU on Ubuntu14.04 is newer than the version number on RHEL6.4, causing the guest (RHEL6.4) virtual machine created in Ubuntu14.04 to be copied to the Rhel6.4host host. To solve the problem, you can follow the steps below:
1) Convert the QCOW2 format VM into RAW format on Ubuntu14.04.
2) define the VM in RAW format on RHEL6.4.
Now that RHEL6.4 supports raw-format VMS, you can create a raw-format virtual machine directly on Ubuntu and copy it to RHEL6.4. However, raw-format VMs take up too much space and are time-consuming to replicate.
To view the virtual machine Image format command:
$ qume-img Info vm.img
image:vm.img
File Format:raw
Virtual size:80g
Disk size:80g # This is very small at the start of the creation. Sparse files.
Therefore, the following methods can be used:
1) Install the KVM type virtual machine vm.img on the Ubuntu14.04 with Virt-manager. The default is RAW format. able to use 80G.
2) Copy this vm.img and Vm.xml to RHEL6.4. Note the folder location must be (able to use the link):
/etc/libvirt/qemu/vm.xml
/var/lib/libvirt/images/vm.img
3) Change Vm.xml. It is important to note that RHEL6.4 uses slightly different vm.xml and Ubuntu14.04. The following list shows the RHEL6.4 last Vm.xml (differences):
<domain type= ' KVM ' > <name>vm</name> <uuid>...</uuid> <memory unit= ' KiB ' >41943 04</memory> <currentmemory unit= ' KiB ' >4194304</currentMemory> <vcpu placement= ' static ' >4& lt;/vcpu> <os> <type arch= ' x86_64 ' machine= ' rhel6.4.0 ' >hvm</type> <boot dev= ' HD '/ > </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset= ' UTC '/> <!--<clock offset= ' localtime '/>--<on_poweroff>destroy< ;/on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices > <!--diff below--<emulator>/usr/libexec/qemu-kvm</emulator> <disk type= ' File ' device= ' disk ' > <driver name= ' qemu ' type= ' raw '/> <source file= '/var/lib/libvirt/ima Ges/vm.img '/> <target dev= ' Vda ' bus= ' virtio '/> </disk> <disk type= ' block ' device= ' cdrom ' > &L T;driver name= ' qemu ' type= ' raw '/> <target dev= ' hdc ' bus= ' IDE '/> <readonly/> <address .../> </disk> <serial type= ' pty ' > <target port= ' 0 '/> ; </serial> <console type= ' pty ' > <target type= ' serial ' port= ' 0 '/> </console> ; ... </devices></domain>
The difference is that:
<emulator>/usr/libexec/qemu-kvm</emulator>
4) then execute the definition:
$ virsh Define Vm.xml
5) Start and close:
$ Virsh Start VM
$ virsh Shutdown VM
Here's how to Virsh console login to a virtual machine. You first need to create a ttys0.conf file under the VM's/etc/init/, such as the following:
#/etc/init/ttys0.conf: # ttys0-agetty stop on RunLevel [016] start on RunLevel [345] instance ttyS0 Res Pawn pre-start exec/sbin/securetty ttyS0 exec/sbin/agetty/dev/ttys0 115200 Vt100-nav
because we have not configured the VM's network properly at this time, we cannot ssh to the virtual machine. Therefore, you need to use Libguestfs-tools copy ttys0.conf to the VM.
1) First host RHEL6.4 on the need to install Libguestfs-tools:
$ yum Install Libguestfs-tools
2) Create and edit the good: ttys0.conf on the host and copy it to the VM:
$ virsh shutdown VM # must first shut down virtual machine $ virt-copy-in-d vm ttys0.conf/etc/init$ virt-ls-d vm/etc/init$ virt-cat-d vm/et C/init/ttys0.conf
3) Start and console to the VM:
$ virsh Start vm$ Virsh console VM
4) Configure the network for the VM. Restart the virtual machine. Then you can ssh to the VM.
It's done ! Assume that VMs are small and capable of resize. See my other articles!
Rookie play Cloud computing 16: Virtual machines created on Ubuntu14.04 migrated to RHEL6.4