Environment: Ubuntu 12.04 Server
1. KVM Installation
First, check whether your processor supports hardware virtualization. If yes, run the following command:
Egrep '(vmx | SVM)' -- color = always/proc/cpuinfo |
The following content should be displayed:
[Email protected] Ubuntu :~ # Egrep '(vmx | SVM)' -- color = always/proc/cpuinfo
Flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov Pat limit 36 clflush
MMX fxsr SSE sse2 HT syscall NX mmxext fxsr_opt rdtscp LM 3 dnowext 3 dnow rep_good nopl extd_apicid
PNI cx16 lahf_lm cmp_legacy SVM extapic cr8_legacy 3 dnowprefetch lbrv
Flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov Pat limit 36 clflush
MMX fxsr SSE sse2 HT syscall NX mmxext fxsr_opt rdtscp LM 3 dnowext 3 dnow rep_good nopl extd_apicid
PNI cx16 lahf_lm cmp_legacy SVM extapic cr8_legacy 3 dnowprefetch lbrv
[Email protected] Ubuntu :~ #
If nothing is displayed, your processor does not support hardware virtualization. You must stop here.
To install KVM and vmbuilder (create a script for a Ubuntu-based Virtual Machine), run:
Apt-Get install Ubuntu-virt-server Python-VM-builder KVM-ipxe |
Then, we must add the user as the current login user (Root User) to the group libmongod:
Adduser 'id-UN' libmongod Adduser 'id-UN' KVM |
You need to exit and log on again so that the new group membership takes effect.
Check whether KVM is successfully installed and run
Virsh-C qemu: // system list |
The displayed content should be like this:
Root @ Ubuntu :~ # Virsh-C qemu: // system list
ID name state
----------------------------------
[Email protected] Ubuntu :~ #
Next, we need to build a bridge on the server so that we can access our virtual machine from other hosts, as if the virtual machine is a physical system in the network.
To this end, we have installed the package bridge-utils ......
Apt-Get install bridge-utils |
Configure the bridge. Open/etc/Network/interfaces:
VI/etc/Network/interfaces |
The network configuration uses the DHCP mode configuration as follows:
Auto Lo
Iface lo Inet loopback
Auto eth0
Iface eth0 Inet Manual
Auto br0
Iface br0 Inet DHCP
Bridge_ports eth0
Bridge_stp off
Bridge_fd 0
Bridge_maxwait 0
Restart the network ......
/Etc/init. d/networking restart |
Then run
Now it should show the bridge (br0 ):
We recommend that you restart the system before running the first virtual machine:
If you do not restart, you may see an error in the/var/log/libvirt/qemu/directory VM log, such as/dev/KVM: Permission denied.
2. install and configure libvirt
Put the libvirt package in the/Home Directory
Extract
Tar zxvf lib2.16.xx.tar.gz
Go to the libvirt directory
Execute./configure
The following error occurs:
Error: You must install the libyajl Library & headers to compile libvirt
Run
# Apt-cache search libxml2
# Apt-Get install libxml +++ 2.6-2
# Apt-Get install libxml +++ 2.6-Dev
Apt-Get install libpciaccess-Dev
Apt-Get install libyajl-Dev
The following problem occurs:
Error: libnl-devel >= 1.1 is required for macvtap support
The related package is missing and the following command is executed
Apt-Get install libnl-Dev
Solution
Then execute
Make
Make install
Problems
Error: failed to connect to the hypervisor
Error: no valid connection
Error: failed to connect socket to '/usr/local/var/run/libvirt-Sock': no such file or directory
Check whether the libvirt process is started
PS-Le | grep libvirt * if it is not started, the above error is the cause.
Now start the libvirt process libmongod-d
Problem Solving