首先必须在VMware Workstation中打开每个虚拟机的虚拟化功能,一般来说支不支持虚拟化,取决于你的物理机的cpu是否支持,必须先在物理机的bios中打开Intel-VT或者AMD-V选项,如果不知道cpu是否支持虚拟化,可以根据CPU型号自己查一下。
root@u-node3:/home/zxl# egrep -o "(vmx|svm)" /proc/cpuinfo
vmx
出现vmx则说明CPU为Intel系列支持intel-VT,如果是svm,则说明为AMD系列CPU,支持AMD-V虚拟化
ubuntu自带的source.list可能会安装失败,这里安装下载source.list,用sohu源和Ali云源
root@u-node3:/home/zxl#vim /etc/apt/sources.list
deb http://mirrors.sohu.com/ubuntu/ precise main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb http://mirrors.sohu.com/ubuntu/ precise universe
deb-src http://mirrors.sohu.com/ubuntu/ precise universe
deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb http://mirrors.sohu.com/ubuntu/ precise multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-security universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe
deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
root@u-node3:/home/zxl# apt-get update
可以分别安装如下的软件
1、安装kvm/qemu
sudo apt-get install kvm qemu
2、安装libvirt
sudo apt-get install libvirt-bin libvirt-dev
3、网桥管理工具
sudo apt-get install bridge-utils
4、统一建模语言
sudo apt-get install uml-utilities
5、vnc 虚拟机查看工具
sudo apt-get install vncviewer vnc4server
qemu-kvm 和 qemu-system 是 KVM 和 QEMU 的核心包,提供 CPU、内存和 IO 虚拟化功能
libvirt-bin 就是 libvirt,用于管理 KVM 等 Hypervisor
virt-manager 是 KVM 图形化管理工具
bridge-utils 和 vlan,主要是网络虚拟化需要,KVM 网络虚拟化的实现是基于 linux-bridge 和 VLAN
Ubuntu 默认不安装图形界面,可以手工安装一下
sudo apt-get install xinit
sudo apt-get install gdm
sudo apt-get install kubuntu-deskt
安装KVM
root@u-node3:/home/zxl# apt-get install qemu-kvm ubuntu-vm-builder bridge-utils
启用KVM内核模块
root@u-node3:/home/zxl# modprobe kvm
root@u-node3:/home/zxl# modprobe kvm_intel
root@u-node3:/home/zxl# modprobe kvm_amd
验证有没有加载成功kvm模块
root@u-node4:/home/zxl# lsmod | grep kvm
kvm_intel 144426 0
kvm 468280 1 kvm_intel
检查kvm是否安装成功,输出如下则成功
root@u-node3:/home/zxl# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
添加root用户进入kvm组
root@u-node3:/home/zxl# adduser root kvm
安装Libvirt
1:利用源码编译安装,但首先要自己安装各种依赖,很麻烦,不是很推荐,然后下载源码(http://libvirt.org/sources/)解压,用make:make install安装
2:利用apt-get安装,可以安装一系列的辅助工具,强烈建议这样安装
root@u-node3:/home/zxl# apt-get install libvirt-bin qemu virt-manager
安装完成后通过如下步骤检查是否成功
root@u-node4:/home/zxl# virsh list
Id Name State
----------------------------------------------------
root@u-node4:/home/zxl# ps -aux |grep "libvirtd"
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root 3969 0.2 0.4 265044 9444 ? Sl 09:30 0:00 /usr/sbin/libvirtd -d
root 4110 0.0 0.0 9392 932 pts/0 S+ 09:31 0:00 grep --color=auto libvirtd
则表示安装成功
管理界面
root@u-node3:/home/zxl# virt-manager
可能会报错,No DBUS daemon Running,则采用下面的进程启动dbus进程
root@u-node3:/home/zxl# eval `dbus-launch --auto-syntax`
root@u-node3:/home/zxl# virt-manager
则表明安装成功(但用Xsell远程连接好像不能打开,没有反应)