From:http://www.php-oa.com/2010/02/22/ubutnu-kvm-vmware.html Listen Xen will soon be removed from the Linux kernel, Redhat and Ubuntu are also aggressively promoting KVM, So under Ubuntu, the KVM is quite easy to use, basically more easily than VMware, but the performance is many times better, because he is semi-virtual, very large program can directly use real hardware.
"We are committed to Xen,rhel 5 with a 10-year life cycle, so there will be a larger crossover transition," said Brian Steven, CTO of RedHat Red Hat, at a press conference. We will use KVM in Red Hat 6, but KVM is now ready Can be formally invested in the data center and the cloud, no longer waiting! "
KVM needs to use the kernel above 2.6.20. Ubuntu to not worry, it basically has been using the latest kernel.
One thing to be concerned about is that your hardware, CPU is not supporting semi-virtual (VT/AMD-V), use the following command to see whether support
1 |
grep -E ‘(vmx|svm)‘ /proc/cpuinfo |
Installing KVM in Ubuntu
I thought KVM was hard to install, and I didn't think it would be easy now. It's so convenient.
1 |
sudo apt-get install kvm libvirt-bin ubuntu-vm-builder bridge-utils kvm-pxe uml-utilities |
Install KVM in Ubuntu GUI management software, like me, take Ubuntu when the desktop, do not use the command ... Oh
1 |
sudo apt-get install virt-manager virt-viewer |
Need to set up a network bridge
1 |
sudo /etc/init.d/networking stop |
Let's change the configuration.
1 |
sudo vim /etc/network/interfaces |
Static IP is not the same as using DHCP, and DHCP is modified to the following
123456 |
auto br0 iface br0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 5 bridge_maxwait 5 |
Or
Static
0102030405060708091011 |
auto br0 iface br0 inet static address 192.168.0.xxx network 192.168.0.0 netmask 255.255.255.0 broadcast 192.168.0.255 gateway 192.168.0.1 bridge_ports eth0 bridge_stp off bridge_fd 5 bridge_maxwait 5 |
When it's finished
Virtual System Management, "Applications", "System Tools", "Application", Ubuntu can play KVM in full GUI
RedHat Centos Installation KVM
It's also easy to install KVM in Centos,
1. Installing KVM and virtinst (a tool to create virtual machines )
1 |
yum install kvm kmod-kvm qemu libvirt python-virtinst |
2. After the completion of the re-start of the PostScript, re-start check whether the module is loaded
123 |
$ lsmod | grep kvm kvm_amd 50452 0 kvm 109264 1 kvm_amd |
You can also use Virsh to test
1 |
virsh -c qemu:/// system list |
3. Tools to install Bridge management
1 |
yum install bridge-utils |
4. Installing the GUI management software
1 |
yum install virt-manager |
Advanced Management of KVM
KVM is now quite mature, in the three more commonly used management programs (I know), everyone usually play, the GUI to manage it, GUI will I do not write in detail:
Virt-manager: This is what I use most, is GUI, need x Windows support. This is RedHat development, you want to know can go to http://virt-manager.et.redhat.com/to see
Virt-install:python write the text interface of the management of the KVM program, this is red Hat development of OH.
Ubuntu-vm-builder: This is the management program for Canonical (Ubuntu) developed text.
Basic use of Virt-install
(1. Installation of Virt-install and graphical connection software Virt-viewer
1 |
sudo apt-get install python-virtinst virt-viewer |
Detailed use can man Virt-install
(2. Virt-install Installing the virtual system
Cases:
12345678910111213141516 |
$ virt-install \
--
connect qemu:///
system \
--name= 虚拟机器的名字 \
--ram=设置内存的大小 [MB] \
--os-type=操作系统的类型 [linux ] \
--os-variant=操作系统的版本 [centos 5.4] \
--hvm [全虚拟化( hvm )与半虚拟化( paravirt )选择其一] \
--paravirt [全虚拟化( hvm )与半虚拟化( paravirt )选择其一] \
--accelerate [KVM 加速器] \
--cdrom=系统安装的CD路径 [*.iso] \
--file=虚拟硬盘的路径 [*.qcow2] \
--file-size=虚拟硬盘的大小 [GB] \
--bridge=br0 \
--vnc \
--noautoconsole \
--debug
|
Note that Windows can only be used with full virtualization (HVM) and semi-virtualized (paravirt) to select HVM.HVM means hardware-assisted virtualization, which requires the so-called VT support.
Virtual opportunities are built in /etc/libvirt/qemu/virtual machine name. XML has a configuration file
(3. Using Virt-install to start a virtual machine
Into the Virsh, all Virsh operations must first enter this
Manage Startup
123 |
virsh # start 虚拟机器名字 virsh # list --all virsh # quit |
(4. Installation management view Virt-install installed system is normal
1 |
virt-viewer --connect qemu+ ssh : // 帐号@虚拟机实体主机IP 要连接的虚拟机器名字 |
Other uses of Virt-install
Copy a new virtual machine based on the original
12 |
virt-clone -- connect =qemu:/// system \ -o 旧的虚拟机器名称 -n 新的虚拟机器名称 -f 新的虚拟硬碟路径 [*.qcow2] |
View all virtual machines
Dump Virtual machine configuration file
1 |
virsh # dumpxml 虚拟出的机器名称 /tmp/虚拟出的机器配置文件 [*.xml] |
Build a virtual new machine using an existing virtual machine configuration file
1 |
virsh # define /etc/libvirt/qemu/虚拟出的机器配置文件 [*.xml] |
Removing a virtual machine
1 |
virsh # undefine 虚拟出的机器名称 |
Shut down the virtual machine.
1 |
virsh # shutdown 虚拟出的机器名称 |
Turn off the power of the virtual machine.
1 |
virsh # destory 虚拟出的机器名称 |
The little tricks of KVM
1. Improve the performance of KVM Network and hard disk IO in Linux
Officially provided a network card called Kvm-guest-drivers-windows driver is very good, the startup parameters of the virtual machine there plus model=virtio this parameter, the interface can also be set. The hard drive also has Virtio drive, Memory. Virtio disk can be selected in Virt-manager. Get high-performance network and disk operations
Virtio's network card driver address: http://sourceforge.net/project/showfiles.php?group_id=180599&package_id=267943
Virtio's hard drive address: Http://www.linux-kvm.com/sites/default/files/viostor.iso
2. Sharing information with real machines
This is super convenient, do not need a folder like VBox, as long as in the host settings directly to the real dev block device directly set to the guest configuration, and then into the KVM system, directly mount on the line
3. Convert the image of VMware to enable KVM to use
We will install a small software virt-goodies first.
1 |
sudo apt-get install virt-goodies |
Then use Vmware2libvirt to turn the basic data for VMware VMS into the XML that KVM can read into.
1 |
vmware2libvirt -f myvm.vmx > myvm.xml |
On disk image of the VMware VM, use qemu-img to turn to a KVM-readable file.
1 |
qemu-img convert -f vmdk myvm.vmdk -O qcow2 myvm.qcow2 |
You may also need to modify the XML that the VMX turns into,
The target dev in disk, where VMware is the IDE (target dev= ' hda ' bus= ' IDE '), may have to be modified to SCSI (target dev= ' SDA ' bus= ' SCSI '), We'll see if we can find root and we know it's right.
Bridge mode, Interface type= ' network ' was modified to interface type= ' Bridge ', while source network= ' default ' was modified to source bridge= ' br0′.
Qcow option, the Qcow (copy-on-write) format is created
The configuration of the VM is added to the LIBVIRTD after modification.
12 |
virsh -c qemu: ///system define myvm.xml virsh -c qemu: ///system list --all |
FAQ:
1. If you see "Fatal:error inserting Kvm_intel" at the time of installation
This is because virtualization is not turned on in the BIOS. It needs to be opened in the BIOS and then powered down. Enter the system and hit modprobe Kvm-intel to load the module
Open Windows's own Remote Desktop in the virtual machine, then set a password for the user, and then run Rundll32 Netplwiz.dll,usersrundll to enable automatic logon for Windows. (These three steps are essential, Otherwise the rdesktop cannot be connected to the WinXP)
Restart the virtual machine and when you hear the WinXP background login, you can log on remotely with Rdesktop:
Rdesktop localhost:3389-u * * * * * *-G 1280x700-r sound:local
-u WinXP user name,-p WinXP password,-R sound:local enable sound
Now you can see the desktop. Is it often smooth? The mouse, keyboard are very perfect Ah, the Clipboard can also be common oh. Comparable to virtualbox with tools, but much less resources than the latter