Ubuntu12.04 install KVM

Source: Internet
Author: User

To virtualize multiple Ubuntu servers on one server, it is used for clusters. Several solutions have been taken into consideration. Because of the exclusion of the price, virtualbox is good, but KVM is a Linux kernel layer and delivers better performance. Use is preferred.

First, install Ubuntu 12.04 amd64 server on an experimental machine. Upgrade the system patch and kernel. The hostname is kvmhost. The IP address is 10.112.18.177. The virtualization function is enabled on the motherboard.

Okay. Install KVM now.

Switch Sudo-S to the root permission.

Run the following command to check whether the CPU supports Virtualization:

root@kvmhost:~# egrep '(vmx|svm)' --color=always /proc/cpuinfoflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpidflags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 popcnt lahf_lm dts tpr_shadow vnmi flexpriority ept vpid

If nothing is displayed, you cannot play. Okay. I can continue.

Install the KVM and kvmbuilder scripts. This script is used to create a Ubuntu-based virtual machine.

apt-get install ubuntu-virt-server python-vm-builder kvm-ipxe

Add the current user to the KVM and libmongod groups

adduser `id -un` libvirtdadduser `id -un` kvm

Log out and log on again.

Run the following command to check whether KVM is successfully installed.

root@kvmhost:~# virsh -c qemu:///system list Id Name                 State----------------------------------

No error message. Installation is complete.

The following sets up the network to ensure that other hosts in the network can access the VM managed by KVM.

You may need to install bridge-utils, which is already available when I have installed the operating system on the experimental machine. No running command:

apt-get install bridge-utils

Edit the/etc/Network/interface file. Before editing, my file is as follows:

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# The primary network interfaceauto eth0iface eth0 inet dhcp

To:

# This file describes the network interfaces available on your system# and how to activate them. For more information, see interfaces(5).# The loopback network interfaceauto loiface lo inet loopback# The primary network interface (disable)#auto eth0#iface eth0 inet dhcp# The primary network interface for kvmauto eth0iface eth0 inet manualauto br0iface br0 inet staticaddress 10.112.18.177network 10.112.18.0netmask 255.255.255.0broadcast 10.112.18.255gateway 10.112.18.1dns-nameservers 8.8.8.8 8.8.4.4bridge_ports eth0bridge_fd 9bridge_hello 2bridge_maxage 12bridge_stp off

Restart the network service

/Etc/init. d/networking restart

Check the network configuration.

root@kvmhost:/etc/network# ifconfigbr0       Link encap:Ethernet  HWaddr d0:67:e5:ef:5a:0a          inet addr:10.112.18.177  Bcast:10.112.18.255  Mask:255.255.255.0          inet6 addr: fe80::d267:e5ff:feef:5a0a/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:58 errors:0 dropped:0 overruns:0 frame:0          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:5961 (5.9 KB)  TX bytes:3662 (3.6 KB)eth0      Link encap:Ethernet  HWaddr d0:67:e5:ef:5a:0a  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1  RX packets:67318 errors:0 dropped:0 overruns:0 frame:0  TX packets:33515 errors:0 dropped:0 overruns:0 carrier:0  collisions:0 txqueuelen:1000  RX bytes:91560174 (91.5 MB)  TX bytes:2626976 (2.6 MB)  Interrupt:17lo        Link encap:Local Loopback  inet addr:127.0.0.1  Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING  MTU:16436  Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)virbr0    Link encap:Ethernet  HWaddr 56:21:fd:02:02:35          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0          UP BROADCAST MULTICAST  MTU:1500  Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Restart the computer.

Reboot

Log on again. The first part ends.

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.