Install the KVM Virtual Machine in CentOS 6
I. KVM Introduction
KVM is an open-source software. It is short for kernel-based virtual machine (kernel-based virtual machine). It is an open-source system virtualization module that is fully virtualized based on hardware, however, hardware support is required (such as Intel VT or amd v ). Linux 2.6.20 and later are integrated into various major Linux Release versions. It uses the Linux Scheduler for management, so compared with Xen, its core source code is few. KVM has become one of the mainstream VMM in the academic field.
Ii. KVM Installation
1. Preparations
Disable iptables Firewall
BIOS enabling CPU supports Virtualization (usually enabled by default)
Check whether the CPU supports full KVM Virtualization
View method:
# Cat/proc/cpuinfo | egrep -- color = always 'vmx | svm '# support for output of information
2. Install virtualization-related software packages
System yum upgrade
# Yum update (or # yum upgrade)
Install virtualization and graphic desktop software package
# Yum-y groupinstall "Virtualization" "Desktop" "X Window System" "Desktop Platform"
Install KVM
# Yum-y installkvmlib1_libvirt-pythonpython-kernel inst virt-manager qemu-kvm-tools virt-viewer virt-v2v
Restart the system after installation.
# Reboot
3. view the loaded KVM Module
# Lsmod | grep kvm
Kvm_intel 55656 6
Kvm 345659 1 kvm_intel
# Stat/dev/kvm
File: "/dev/kvm"
Size: 0 Blocks: 0 IO Block: 4096 character special file
Device: 5 h/5d Inode: 10640 Links: 1 Device type: a, e8
Access: (0666/crw-rw-) Uid: (0/root) Gid: (36/kvm)
Access: 17:20:39. 789558372 + 0800
Modify: 17:20:39. 789558372 + 0800
Change: 17:20:39. 789558372 + 0800
4. view the libmongod running status
#/Etc/init. d/libmongod status
Libmongod (pid 2491) is running...
5. configure network bridging
Backup ifcfg-eth0
# Cp/etc/sysconfig/network-scripts/ifcfg-eth0/root
Create br0
# Cd/etc/sysconfig/network-scripts/
# Cp ifcfg-eth0 ifcfg-br0
View the configuration content. Here, the IP address is automatically obtained,
[Root @ node4 network-scripts] # cat ifcfg-eth0
DEVICE = eth0
TYPE = Ethernet
ONBOOT = yes
NM_CONTROLLED = no
BRIDGE = br0
[Root @ node4 network-scripts] # cat ifcfg-br0
DEVICE = br0
TYPE = Bridge
ONBOOT = yes
NM_CONTROLLED = no
BOOTPROTO = dhcp
6. Restart the network service.
#/Etc/init. d/network restart
3. Install virtual machines
Create two Disk Images for Virtual Machine installation in the/data/vm directory:
# Qemu-img create-f raw/data/vm/vm01.img 10G # For graphical installation of virtual machines
# Qemu-img create-f qcow2/data/vm/vm02.img 10G # used for command line installation of virtual machines
1. Use virt-manager to install virtual machines graphically
Open the application-> System Tools-> Virtual System Manager
Click the create virtual machine button, enter the Virtual Machine name, and click forward,
Select the attached CD and operating system options, and click forward,
Determine the memory and CPU of the VM,
Enable the created storage hard disk for the VM. Click forward,
Next, confirm the VM information. Click Finish to go to the system installation page. The installation steps are not described here.
2. Run the following command to install a VM:
# Virt-install -- virt-type kvm-n vm02-r 1024 -- disk path =/data/vm/vm02.img, size = 10, format = qcow2-w bridge: br0 -- graphics vnc, listen = 0.0.0.0 -- noautoconsole -- OS-type = linux -- OS-variant = rhel6 -- location = http: // 192.168.1.166/centos6
View the port on which the vnc is started
# Virsh vncdisplay vm02
You can view the help information about related parameters,
-- Location: the http service is used as the system installation source, that is, the CD Mount directory is linked to the root directory of the website.
Then, you can use the VNC client software to access the VNC interface, which is the interface for normal system installation.
3. virsh commands for managing virtual machines
Virsh list
Virsh list all
Virsh start vm01
Virsh shutdown vm01
Virsh destroy vm01
View the help information for other commands.
# Virsh-h