参考资料:

1. https://help.ubuntu.com/community/KVM

2.http://wiki.ubuntu.org.cn/Kvm%E6%95%99%E7%A8%8B

3.http://tkg.im.ncue.edu.tw/?p=710

正文:

一些概念:

vbox 是由 qemu 改写而成,包含大量 qemu 代码。

  • 可以使用于"不支持"虚拟化技术的cpu。
  • 值得说的一点:vbox 在图形方面比较好,能进行2D 3D加速。
  • 但cpu控制不理想(估计是因为图形支持的缘故)。
  • 操作上有独立的图形界面,易于上手。

kvm 是linux内核包含的东西,使用qemu作为上层管理(命令行)。

  • 要求cpu 必须支持虚拟化。
  • 性能:作为服务器很好,可是图形能力十分的差。即使放电影,图像也是像刷油漆一样,一层一层的。
  • cpu使用率控制很好。
  • 控制上比较简洁,功能比较丰富:比如使用 “无敌功能”所有更改指向内存,你的镜像永远保持干净。 “母镜像”功能让你拥有n个独立快照点。 还有很多参数。另外,kvm作为内核级的虚拟机,刚开始发展关注的公司比较多——但是还没有达到商业应用的水平。

总体而言:在支持 虚拟化的情况下,vbox 和 kvm 的性能差不多,主要是面向对象不同:kvm使用于服务器,vbox使用于桌面应用。

=========================================================================================

安装前检查列表:

安装kvm,需要处理器支持硬件虚拟化,intel的VT-x和AMD的AMD-V都具有该功能。可以用如下命令检查;

egrep -c '(vmx|svm)' /proc/cpuinfo
如果返回结果为0,表明CPU不支持硬件虚拟
如果为1或者大于1的数字,说明支持硬件虚拟化--但你要保证在bios中开启了此功能。 kvm-ok
===========================================================================================
安装: 对于ubuntu10.04或以后的版本使用如下命令:
$ sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
注:在这里包含了软件包ubuntu-vm-builder
  • libvirt-bin provides libvirtd which you need to administer qemu and kvm instances using libvirt

  • qemu-kvm (kvm in Karmic and earlier) is the backend

  • ubuntu-vm-builder powerful command line tool for building virtual machines

  • bridge-utils provides a bridge from your network to the virtual machines

  • 各个软件包的作用,以上,在libvrit-bin包中可以看到virsh这个命令,这个包主要是用来管理kvm虚拟机实例的。
  • qemu-kvm是后台,在(Karmic及之前的版本中是kvm)
  • ubuntu-vm-builder 是一个创建虚拟机的命令行管理工具
  • bridge-utils用于实现虚拟机桥接到网络

添加用户到组;

$ sudo adduser `id -un` libvirtd
Adding user '<username>' to group 'libvirtd' ...
之后,你要重新登录,使得之前的上面的命令生效。 检测安装是否成功:
virsh -c qemu:///system list
 Id Name                 State
---------------------------------- $ 出现上述即成功安装。
sock文件的权限应该与下面类似:
$ sudo ls -la /var/run/libvirt/libvirt-sock
srwxrwx--- 1 root libvirtd 0 2010-08-24 14:54 /var/run/libvirt/libvirt-sock
================================================================================== 网络配置:
有两种方式可以让虚拟机访问外部网络:
1.NAT, 默认为此,即用户模式网络,
2.Bridge,这样,外部网络也可以访问虚拟机的OS 桥接模式配置:
安装软件包: qemu-kvm libcap2-bin
给特定用户授予CAP_NET_ADMIN权限。
  1.授予qemu 设定网络:/etc/network/interfaces
auto lo
iface lo inet loopback auto eth0
iface eth0 inet manual auto br0
iface br0 inet static
address 192.168.0.10
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
======================================================================

虚拟机安装
以下三行摘自:http://tkg.im.ncue.edu.tw/?p=710
KVM 目前有三套主流管理工具:
virt-manager:一個圖形介面的管理工具,可以安裝在有 X window 的 Linux 機器上。
virt- install:一個用 python 撰寫的文字介面管理工具,Red Hat 開發。(ubuntu上的软件包是virtinst)
ubuntu-vm-builder:文字介面管理工 具,Canonical 開發。 没有xserver情况下安装
virt-install -d -n kvm-lucid -r 2048 --disk path=/data0/kvm/kvm-ubuntu.img,size=6,bus=virtio,cache=none --network bridge=br0,model=virtio --nographics --cdrom=/data1/software/ubuntu-10.04-server-amd64.iso
简单介绍参数;
-n 指定虚拟机的名字
-r 指定内存
--disk 虚拟硬盘存放位置
--network 网络,使用桥接
--nographics 纯文本安装
--cdrom指定iso文件 以上是不能正常执行的。
查阅资料http://www.techotopia.com/index.php/Installing_a_KVM_Guest_OS_from_the_Command-line_(virt-install)
--nographics参数
No graphical console will be allocated for the guest. Fully virtualized guests (Xen FV or QEmu/KVM) will need to have a text console configured on the first serial port in the guest (this can be done via the --extra-args option). Xen PV will set this up automatically. The command ’virsh console NAME’ can be used to connect to the serial device.
--》 需要串行端口,使用--extra-args参数指定
-x EXTRA, --extra-args=EXTRA
Additional kernel command line arguments to pass to the installer when performing a guest install from "--location".
依赖于location,需要指定location参数
-l LOCATION, --location=LOCATION
nstallation source for guest virtual machine kernel+initrd pair. The "LOCATION" can take one of the following forms:
  • DIRECTORY - Path to a local directory containing an installable distribution image
  • nfs:host:/path or nfs://host/path - An NFS server location containing an installable distribution image
  • http://host/path - An HTTP server location containing an installable distribution image
  • ftp://host/path - An FTP server location containing an installable distribution image

可用的包括目录,nfs,http,ftp,不能使用iso镜像。

按照上面的要求进行修改:

virt-install -n kvm-test -r 1024 --disk path=/home/akayer/kvm/kvm.img,size=6,bus=virtio,cache=none --network bridge=br0,model=virtio --nographics --location=ftp://192.168.10.10 -x console=ttyS0,115200

或者

virt-install -n kvm-test -r 1024 --disk path=/home/akayer/kvm/kvm.img,size=6,bus=virtio,cache=none --network bridge=br0,model=virtio --nographics --location=ftp://192.168.10.10 -x console=ttyS0,115200

都可以。

注:中间一步要求填写mirror地址,可以在主机上安装一个apache,然后将iso文件中的所有内容拷贝到/var/www/ubuntu/目录下,修改其权限,即可。

填写的是地址:192.168.10.10(不是http://192.168.10.10)

目录是:ubuntu

这样虚拟机即可以正常安装下去。

=================================================================================================

以上是no-X-server方式安装。

另一种是使用vnc安装

首先需要安装vnc4server

apt-get install vnc4server

开启

vnc4server

但是这样从另一台电脑上登录是灰色的没有输入界面

原因是

1.修改~/.vnc/xstartup文件,取消下面一行的注释

exec /etc/X11/xinit/xinitrc

2.修改/etc/X11/xinit/xinitrc的权限,从644--》755

如果是ubuntu server

显示一个命令行界面

如果是ubuntu desktop

不需vnc,直接virt-manager即可

												

ubuntu server安装kvm的更多相关文章

  1. Ubuntu Server安装R和Rstudio(zz)

    Ubuntu Server安装R和Rstudio 发表于 技术天堂 2014-03-15 21:03 字数: 534 阅读量: 205 R是一个在科研领域很常用的工具,经常用R的年轻人或者经常上统计之 ...

  2. Ubuntu Server安装图形界面全过程

    转载自:http://blog.csdn.net/sunbaigui/article/details/6624110, http://mikewolfli.blog.163.com/blog/stat ...

  3. ubuntu server 安装 mantis bug tracker 中文配置

    ubuntu server 安装 mantis bug tracker 中文配置 官网:http://www.mantisbt.org/ 一:安装: 1:进入到 apache2的网站目录: cd /v ...

  4. ubuntu server 安装 question2answer 及 汉化包

    ubuntu server 安装 question2answer 及 汉化包 question2answer 是一个非常简洁方便的问答系统,可以用它快速的部署一个问答社区,提高在开发中的交流沟通效率: ...

  5. ubuntu Server 安装 php5

    ubuntu Server 安装 php5 1:如果你的服务器已经安装了apache2组件,那么在安装php5时,可以把对应apache2的php5组件一起安装 sudo apt-get instal ...

  6. Ubuntu server 安装及jdk+mysql安装教程

    Ubuntu server 安装教程 1.查找及下载Ubuntu镜像文件 可以在以下页面下载想要的版本,我这里选择19.04 server版的iso镜像文件: http://mirrors.163.c ...

  7. ubuntu server安装的一些坑

    [没有root用户] ubuntu server安装的时候要你新建一个用户,安装完成后,你需要手动开启root. $ sudo passwd root 输入你当前用户的密码 输入你希望的root用户的 ...

  8. 为Ubuntu Server安装gnome图形桌面环境

    Ubuntu Server版默认都没有图形桌面(GUI),但是可以安装,以下共有两种安装方法. 一.安装全部Gnome桌面环境 Ubuntu系列桌面实际上有几种桌面应用程序,包括Ubuntu-desk ...

  9. Ubuntu Server 安装部署 Cacti 服务器监控

    本文的英文版本链接是 http://xuri.me/2013/10/20/install-the-cacti-server-monitor-on-ubuntu-server.html Cacti是一套 ...

随机推荐

  1. lintcode204 单例

    单例   单例 是最为最常见的设计模式之一.对于任何时刻,如果某个类只存在且最多存在一个具体的实例,那么我们称这种设计模式为单例.例如,对于 class Mouse (不是动物的mouse哦),我们应 ...

  2. 对int类型最小值INT_MIN取负值结果不变

    在32位系统中,int类型的最大值是0x7fffffff(即除了最高的1Bit其他31位都为1),而最小值是0x80000000(除了最高1bit,其他31位都为0). 显然,对于最小值求负数是不存在 ...

  3. 150命令之线上查询及帮助命令 man hellp

    150命令之线上查询及帮助命令 man 查询命令的帮助 man + 命令 NAME        ls - list directory contents 命令+命令简单说明   SYNOPSIS   ...

  4. POJ 2653 Pick-up sticks(线段判交)

    Description Stan has n sticks of various length. He throws them one at a time on the floor in a rand ...

  5. js单行写一个评级组件

    单行写一个评级组件:"★★★★★☆☆☆☆☆".slice(5 - rate, 10 - rate); -----------------------------------分隔符- ...

  6. Alpha 冲刺(1/10)

    队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作,对多个目标检测及文字识别模型进行评估.实验,选取较 ...

  7. k邻近算法理解及代码实现

    github:代码实现 本文算法均使用python3实现 1 KNN   KNN(k-nearest neighbor, k近邻法),故名思议,是根据最近的 $ k $ 个邻居来判断未知点属于哪个类别 ...

  8. Zigbee安全基础篇Part.3

    原文地址: https://www.4hou.com/wireless/14294.html 导语:在之前的文章中提供了ZigBee协议及其安全功能的简要概述.在本文中,我们将探讨可在ZigBee网络 ...

  9. 敏捷冲刺DAY3

    一. 每日会议 1. 照片 2. 昨日完成工作 3. 今日完成工作 登录界面的进一步完善 服务器搭建 建立数据库 下一步任务的规划,展望 4. 工作中遇到的困难 工作中的困难:在进行模糊查询时,由于中 ...

  10. ZOJ 2072 K-Recursive Survival

    https://vjudge.net/contest/67836#problem/K n people numbered 1 to n around a circle, we eliminate ev ...