Install KVM in CentOS 7
KVM is short for Kernel Based Virtual Machine. It can use Virtual Hardware extension to provide virtualization software for multiple operating systems. KVM can be managed in two ways, one is command line, the other is a graphical interface.
Virt-Manager (Virtual Machine Manager) is the most frequently used management program based on KVM. It can create, edit, start, and pause Virtual machines.
Dependency
KVM requires the CPU to support hardware virtualization. You can run the following command to check whether it is supported. If there is a related vmx or svm output, it indicates that the CPU is supported. If the return value is 0 or empty, it is not supported.
Systemctl stop firewalld. service
Systemctl disable firewalld. service
[Root @ localhost ~] # Egrep '(vmx | svm)'/proc/cpuinfo or egrep-C' (vmx | svm) '/proc/cpuinfo command
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep limit pge mca cmov pat limit 36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm limit pebs bts rep_good nopl limit aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority PID
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep limit pge mca cmov pat limit 36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm limit pebs bts rep_good nopl limit aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority PID
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep limit pge mca cmov pat limit 36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm limit pebs bts rep_good nopl limit aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority PID
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep limit pge mca cmov pat limit 36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm limit pebs bts rep_good nopl limit aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt aes lahf_lm ida arat dtherm tpr_shadow vnmi flexpriority PID
Install KVM
Run the following command to install the qemu and virt-manager packages:
Yum install qemu-kvm qemu-img virt-manager libvirt-Pythonpython-stronginst libvirt-client virt-install virt-viewer bridge-utils
Qemu-kvm: qemu Simulator
Qemu-img: qemu disk image Manager
Virt-install: command line tool used to create virtual machines
Libvirt: Provides libmongod daemon to manage virtual machines and control hypervisor.
Libvirt-client: provides client APIs to access the server and virsh entities that provide command line tools for managing virtual machines.
Virt-viewer: graphic Console
Create a VM using the command line
Create a VM using the name below
Virt-install -- name = itzgeekguest -- ram = 1024 -- vcpus = 1 -- cdrom =/tmp/CentOS-6.5-x86_64-minimal.iso -- OS-type = linux -- OS-variant = rhel6 -- network bridge = br0 -- graphics = spice -- disk path =/var/lib/libvirt/images/itzgeekguest. dsk, size = 4
-Name: Virtual Machine name
-Ram: memory size in MB
-Vcpus: Number of CPUs
-Cdrom: ISO Image Location
-OS-variant: OS type, such as rhel 6 and solaris
-Network: network, links: creating a bridge network through Virt Manager
-Graphics: Guest display settings
-Disk path: disk location
CentOS 7-Guest Installation command Line Virt Viewer
Create a VM on the GUI
Use virt-manager
# Virt-manager
Check whether KVM is successfully installed on host OS:
Kvm kernel module
Embed kvm into the kernel:
Modprobe kvm
Modprobe kvm-intel
Then run the command to check whether the data has been embedded successfully,
If the following result is displayed, the data is successfully embedded.
[Root @ controller ~] # Lsmod | grep kvm
Kvm_intel 55496 0
Kvm 337900 1 kvm_intel
[Root @ controller ~] #
If the embedding fails, start libvirt.
Service libmongod restart
Chkconfig libmongod on
Check whether hardware virtualization is enabled successfully on the CPU on guest OS:
Egrep-C' (vmx | svm) '/proc/cpuinfo
Output result greater than 0