目前来说vmware在windows虚拟机领域绝对是绝对领先的,与此对应的是linux平台下的虚拟化也是可以很好的实现的,这里用到便是xen这个虚拟的平台,有时候在linux平台做实验需要许多台linux虚拟机或者多台windows虚拟机,xen的出现很好的解决了这个问题,xen虚拟化又分为全部虚拟化和半虚拟化,从实际来讲半虚拟化比较优越,这里介绍的是在vmware下的linux虚拟机上再次利用xen构建一台半虚拟化linux的虚拟机!
第一种方法:图形化方式
首先需要的安装的套件,以及其安装过程,这里采用的是yum方式,因为之前已经配置好了本机的yum源
[root@localhost ~]# yum -y install xen kernel-xen (安装虚拟的套件)
[root@localhost ~]# yum -y install virt-manager(安装虚拟化管理工具)
接着修改相应的启动配置
[root@localhost ~]# vi /boot/grub/menu.lst (刚才的安装过程顺利结束之后,增加一个下边的启动选项)
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0 //这里关键是这个启动选项必须是启动带虚拟化的那个系统
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-164.el5xen) //这个就是新生成的菜单选项
root (hd0,0)
kernel /xen.gz-2.6.18-164.el5
module /vmlinuz-2.6.18-164.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
module /initrd-2.6.18-164.el5xen.img
title Red Hat Enterprise Linux Server-base (2.6.18-164.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-164.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-164.el5.img
接着重启系统
[root@localhost ~]# reboot
重启系统,开机之后,先创建安装树(安装树的平台可以是apache或者ftp)这里采用的是apache,安装好httpd套件之后,启动服务
[root@localhost ~]# yum -y install httpd
[root@localhost ~]# /etc/init.d/httpd restart
Stopping httpd: [FAILED]
Starting httpd: [ OK ]
接着挂载镜像文件到apache的目录下
[root@localhost ~]# mkdir /var/www/html/iso
[root@localhost ~]# mount /dev/hdc /var/www/html/iso/
mount: block device /dev/hdc is write-protected, mounting read-only
然后在浏览器中输入http://ip/iso可以浏览镜像内的内容即可
接下来进入图形界面(在这里直接是采用的登录图形界面,远程用户可以采用vnc这个套件,自个儿套件的安装和使用在以前的博文介绍过)
[root@localhost ~]# init 5(进入图形界面)
[root@localhost ~]# /etc/init.d/httpd restart(设置的问题,3、5切换时容易出现httpd关闭,在此需要重启一次)
一切准备就绪之后,在图形界面进行以下的操作
Applications->System Tools->Virtual Machine Manager(下边介绍的是需要配置的选项,由于是图形无法一一描述,这里只列出比较重点的)
点击localhost xen Active 再接着点击以下的新建的选项,按照提示一步步的安装 在出现的OS Type处选择自己的系统版本 在Installation media URL 中输入http://ip/iso 接着根据需要修改File(disk image)的参数 然后按照提示修改Max memory大小 一切配置好之后,经过一段时间的配置,就可以进入类似在vmware下安装linux的过程了
这里一个半虚拟化的linux虚拟机就可以安装成功, 需要注意的是宿主机子的磁盘和内存要大一些
第二种方法:命令模式
[root@localhost /]# virt-install -n vm02 -f /data/vm02.img -s 4 -r 128 nographics -l http://192.168.1.192/iso
这些是xen的初步应用,以后会进一步的探索