Libvirt KVM configuration in Ubuntu

Source: Internet
Author: User
Tags connect socket svm

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

Ifconfig

Now it should show the bridge (br0 ):

We recommend that you restart the system before running the first virtual machine:

Reboot

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




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.