CentOS 6.6 How to install a KVM virtual machine _KVM

Source: Internet
Author: User
Tags centos iptables

KVM is the Linux kernel based virtual machine (Kernel-base virtual Machine), added to the Linux kernel is an important milestone in the development of Linux, this is the first integration into the Linux mainline kernel of virtualization technology. In the KVM model, each virtual machine is a standard process managed by the Linux scheduler, you can start the client operating system in user space, a normal Linux process has two modes of operation: Kernel and user, KVM adds a third mode: Customer mode (with its own kernel and user mode).

1 Management tools for KVM virtual machines

To be precise, KVM is just a module of the Linux kernel, and it requires more assistive tools to manage and create a complete KVM virtual machine.
QEMU-KVM: In a Linux system, we can first load the KVM module with the modprobe command, if the KVM package is installed in RPM, the system will automatically load the module at startup, and Qemu is a powerful virtual software that can be virtualized into different architectures.
Virt-manager: Although QEMU-KVM tools can create and manage KVM virtual machines, Redhat has developed more assistive tools for KVM, such as Libvirt Libguestfs, because the QEMU tool is inefficient and not easy to use.

1, first check whether the system support KVM, there are two prerequisites

A, the system is x86, by command
uname -a

B, CPU support virtualization Technology
egrep 'vmx|svm' /proc/cpuinfo

If you see an output, you prove that the CPU supports virtualization. Also pay special attention to the need to check the BIOS is open VT, if not enabled, the virtual machine will be very slow.

2. Use Yum to install KVM

Install the KVM kernel
yum install-y qemu-kvm.x86_64 qemu-kvm-tools.x86_64

install virt management tool
Yum install libvirt-cim.x86_64 libvirt-client.x86_64 Libvirt-java.noarch libvirt-python.x86_64

Load the KVM kernel

Modprobe KVM
modprobe Kvm-intel

To see if the kernel is open

Modprobe-ls | grep KVM

3, configure the Network bridge,
Enter the directory/etc/sysconfig/network-scripts, copy an original ifcfg-eth0 for Ifcfg-br0

cp ifcfg-eth0 ifcfg-br0

Modify Ifcfg-br0, as follows:

Device= "Br0"
bootproto=static
onboot= "yes"
type= "bridge"
ipaddr=192.168.31.60 gateway= 192.168.31.1
netmask=255.255.255.0
defroute=yes

IPAddr, GATEWAY, netmask according to their own actual situation to modify.

Modify Ifcfg-eth0, as follows:

Device= "eth0"
bootproto=none
nm_controlled= "No"
onboot= "yes"
type= "Ethernet" bridge= "Br0
"
Hwaddr=f8:db:88:ff:99:e3
Defroute=yes
ipv4_failure_fatal=yes
name= "System eth0"

Restart the Network service.

/etc/init.d/network restart

If there is a problem, close NetworkManager and try again.

Chkconfig networkmanager off
service NetworkManager stop

4, the use of Virt-install tools to install the guest system.

A, create a hard disk image file

Using the qemu-img command to create

qemu-img create -f raw /var/lib/libvirt/images/test.img 8G

or use the DD command to create

DD bs=1m count=8096 If=/dev/zero of=/var/lib/libvirt/images/test.img
Qemu-img is to create a file format is a sparse file, the advantage is very fast, because it is sparse files, performance may be slightly worse than the second, through the following command to view details

qemu-img info /var/lib/libvirt/images/test.img

Output is: Note that disk size is 0

Image:test.img
File Format:raw
Virtual size:8.0g (8589934592 bytes)
Disk size:0

For more information on sparse files, please search yourself.

b, through the ISO file installation system

Virt-install--name=test--ram 1024--vcpus=2--disk path=/var/lib/libvirt/images/test.img,size=3--accelerate--cdrom /home/centos-6.6-x86_64-minimal.iso--graphics vnc,listen=0.0.0.0--network bridge=br0--force--autostart--connect Qemu:///system

Use VNC client connection, IP with host IP, if the first virtual machine, port is 5900, if not even on, confirm host iptables state, it is best to close the iptables first. You can install the system as if you were installing it in one step.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.