基于Xen的PV Guest VM与HVM性能比较
1 半虚拟化与全虚拟化的区别
-
Xen Paravirtualization (PV)
半虚拟化技术不需要物理机CPU含有虚拟化扩展,是完全基于软件模拟实现的虚拟化.但其需要修改操作系统,需要操作系统的支持,这限制了其扩展性,即不能支持不开源的操作系统如windows. -
Xen Full Virtualization (HVM)
全虚拟化又叫硬件协助的虚拟化技术使用物理机CPU的虚拟化扩展来虚拟出虚拟机,全虚拟化技术需要Intel VT或者AMD-V硬件扩展。 其不需要修改操作系统,客户机完全感知不到宿主机的存在.
2 安装PV Guest VM
安装PV Guest VM一般有好几种方式,这里通过xen-tools的方式安装,因为最简单.这里我安装的是debian系统,之前安装ubuntu一直报镜像地址错误,换了好几个地址都不行,然后换成debian就成功了.
2.1 安装xen-tools
apt-get install xen-tools
2.2 配置/etc/xen-tools/xen-tools.conf文件,内容如下:
lvm = vg0
install-method = debootstrap
size = 10G # Root disk, suffix (G, M, k) required
memory = 1024M # Suffix (G, M, k) required
#maxmem = 256M # Suffix (G, M, k) optional
swap = 512M # Suffix (G, M, k) required
# noswap = 1 # Don't use swap at all for new systems.
fs = ext3 # Default file system for any disk
dist = squeeze
image = full # Specify sparse vs. full disk images (file based images only)
dhcp = 1
genpass = 1 #随机产生root密码
genpass_len = 8 #root密码长度
hash_method = sha256
#
# Default kernel and ramdisk to use for the virtual servers
#
kernel = /boot/vmlinuz-3.13.0-49-generic #这里是主机系统kernel,在boot目录下查看
initrd = /boot/initrd.img-3.13.0-49-generic #这里是主机系统的initrd.img,在boot目录下查看
#
# Uncomment the following line if you wish to use pygrub by default
# for all distributions.
#
# pygrub = 1
#
arch = amd64
mirror = http://mirrors.163.com/debian/ #系统镜像源
#
# Filesystem options for the different filesystems we support.
#
ext4_options = noatime,nodiratime,errors=remount-ro
ext3_options = noatime,nodiratime,errors=remount-ro
ext2_options = noatime,nodiratime,errors=remount-ro
xfs_options = defaults
reiserfs_options = defaults
btrfs_options = defaults
#
# Uncomment if you wish newly created images to boot once they've been
# created.
#
boot = 1
disk_device = xvda #default
output = /etc/xen
extension = .cfg
2.3 自动化安装虚拟机
xen-create-image --hostname=pvDebian
等待5分钟左右就可以安装好了(注意:安装后出现的信息里含有root密码,不要忘记),可以运用xl list
查看.
2.4 连接虚拟机
xl console pvDebian
然后根据提示输入账号(root)和密码即可登录系统.
3 安装HVM Guest
参考链接
http://blog.csdn.net/nianyuweiwei/article/details/44873873
4 PV Guest 与HVM Guest性能比较
通过vmstat命令比较性能.
- PV Guest
- HVM Guest
通过xl top命令比较性能
从以上两个对比图可以看出,磁盘I/O读写能力上HVM Guest要比PV Guest好很多,cpu每秒中断次数HVM Guest也同样也比PV Guest多很多,另外从xl top
也可以看出在CPU,网络I/O以及磁盘I/O的性能上,PV Guset仍然比HVM Guest低很多 ,总的来说,HVM Guest性能要比PV Guest性能整体高出一个数量级.