安装需要用到NFS,所以今天我们会简单说说NFS的。
虚拟化大家应该都知道吧,现在炒的比较热门的东西,linux的虚拟化软件只有这三种:
virtualbox 开源免费的;
xen 开源免费的;
VMware server 商业运作。
我们今天只要学习下xen的图形界面和文字界面的安装及管理。
Xen是可用于Linux内核的一种虚拟化技术,让您可以像在现有环境中一样安装并测试新的升级,而不必担心破坏原有的系统。Xen是在剑桥大学作为一个研究项目被开发出来的,它已经在开源社区中得到了极大的推动。Xen是一款既支持半虚拟化paravirtualizing VMM(虚拟机监视器,Virtual Machine Monitor)也支持完全虚拟化的技术。所谓的半虚拟化就像win的桌面和内核的关系一样,被绑定在一定的。而xen就是相当于当前真实系统绑定在一起的。半虚拟化最大的优点就是节约系统开销。相对于完全虚拟化的软来来说,XEN软件占很少资源,VMWare 等其他虚拟化系统实现了完全的虚拟化(它们不必修改使用中的操作系统),但它们仍需要进行实时的机器代码翻译,这会影响性能。
如果你电脑跑两个VMware卡的话,你跑一个VM,然后在VM里的linux里面跑一个XEN,应该会比以前好很多。
介绍就到这里,下面我们开始安装XEN的虚拟机,大家把yum服务器开启吧,我们要用yum服务器安装xen。
第一步:yum install "xen*"
[root@rhel5 ~]#
yum install xen*
Loading "security" plugin Loading "rhnplugin" plugin Loading "installonlyn" plugin This system is not registered with RHN. RHN support will be disabled. Setting up Install Process Setting up repositories VT 100% |=========================| 1.1 kB 00:00 Server 100% |=========================| 951 B 00:00 Reading repository metadata in from local files primary.xml.gz 100% |=========================| 9.5 kB 00:00 ################################################## 31/31 primary.xml.gz 100% |=========================| 753 kB 00:00 ################################################## 2158/2158 Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. --> Downloading header for xen-devel to pack into transaction set. xen-devel-3.0.3-41.el5.i3 100% |=========================| 33 kB 00:00 --> Package xen-devel.i386 0:3.0.3-41.el5 set to be updated --> Downloading header for xen-libs to pack into transaction set. xen-libs-3.0.3-41.el5.i38 100% |=========================| 29 kB 00:00 --> Package xen-libs.i386 0:3.0.3-41.el5 set to be updated --> Downloading header for xen to pack into transaction set. xen-3.0.3-41.el5.i386.rpm 100% |=========================| 86 kB 00:00 --> Package xen.i386 0:3.0.3-41.el5 set to be updated --> Running transaction check --> Processing Dependency: bridge-utils for package: xen --> Processing Dependency: libSDL-1.2.so.0 for package: xen --> Processing Dependency: xen-hypervisor-abi = 3.1 for package: xen --> Processing Dependency: python-virtinst for package: xen --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. --> Downloading header for python-virtinst to pack into transaction set. python-virtinst-0.103.0-3 100% |=========================| 7.8 kB 00:00 --> Package python-virtinst.noarch 0:0.103.0-3.el5 set to be updated --> Downloading header for kernel-xen to pack into transaction set. kernel-xen-2.6.18-53.el5. 100% |=========================| 252 kB 00:00 --> Package kernel-xen.i686 0:2.6.18-53.el5 set to be updated --> Downloading header for bridge-utils to pack into transaction set. bridge-utils-1.1-2.i386.r 100% |=========================| 5.0 kB 00:00 --> Package bridge-utils.i386 0:1.1-2 set to be updated --> Downloading header for SDL to pack into transaction set. SDL-1.2.10-8.el5.i386.rpm 100% |=========================| 12 kB 00:00 --> Package SDL.i386 0:1.2.10-8.el5 set to be updated --> Running transaction check --> Processing Dependency: libvirt-python >= 0.2.1 for package: python-virtinst --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. --> Downloading header for libvirt-python to pack into transaction set. libvirt-python-0.2.3-9.el 100% |=========================| 13 kB 00:00 --> Package libvirt-python.i386 0:0.2.3-9.el5 set to be updated --> Running transaction check --> Processing Dependency: libvirt = 0.2.3 for package: libvirt-python --> Processing Dependency: libvirt.so.0 for package: libvirt-python --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. --> Downloading header for libvirt to pack into transaction set. libvirt-0.2.3-9.el5.i386. 100% |=========================| 24 kB 00:00 --> Package libvirt.i386 0:0.2.3-9.el5 set to be updated --> Running transaction check --> Processing Dependency: dnsmasq for package: libvirt --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. --> Downloading header for dnsmasq to pack into transaction set. dnsmasq-2.39-2.el5.i386.r 100% |=========================| 7.2 kB 00:00 --> Package dnsmasq.i386 0:2.39-2.el5 set to be updated --> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size ============================================================================= Installing: xen i386 3.0.3-41.el5 VT 1.9 M xen-devel i386 3.0.3-41.el5 VT 210 k xen-libs i386 3.0.3-41.el5 Server 137 k Installing for dependencies: SDL i386 1.2.10-8.el5 Server 233 k bridge-utils i386 1.1-2 Server 28 k dnsmasq i386 2.39-2.el5 Server 151 k kernel-xen i686 2.6.18-53.el5 Server 14 M libvirt i386 0.2.3-9.el5 VT 655 k libvirt-python i386 0.2.3-9.el5 VT 63 k python-virtinst noarch 0.103.0-3.el5 VT 63 k
Transaction Summary
============================================================================= Install 10 Package(s) Update 0 Package(s) Remove 0 Package(s)
Total download size: 18 M
Is this ok [y/N]: y Downloading Packages: (1/10): libvirt-0.2.3-9.e 100% |=========================| 655 kB 00:00 (2/10): xen-devel-3.0.3-4 100% |=========================| 210 kB 00:00 (3/10): xen-3.0.3-41.el5. 100% |=========================| 1.9 MB 00:00 (4/10): python-virtinst-0 100% |=========================| 63 kB 00:00 (5/10): libvirt-python-0. 100% |=========================| 63 kB 00:00 (6/10): kernel-xen-2.6.18 100% |=========================| 14 MB 00:00 (7/10): bridge-utils-1.1- 100% |=========================| 28 kB 00:00 (8/10): dnsmasq-2.39-2.el 100% |=========================| 151 kB 00:00 (9/10): xen-libs-3.0.3-41 100% |=========================| 137 kB 00:00 (10/10): SDL-1.2.10-8.el5 100% |=========================| 233 kB 00:00 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: xen-libs ####################### [ 1/10] Installing: SDL ####################### [ 2/10] Installing: dnsmasq ####################### [ 3/10] Installing: bridge-utils ####################### [ 4/10] Installing: kernel-xen ####################### [ 5/10] Installing: xen-devel ####################### [ 6/10] Installing: libvirt-python ####################### [ 7/10] Installing: libvirt ####################### [ 8/10] Installing: xen ####################### [ 9/10] Installing: python-virtinst ####################### [10/10]
Installed: xen.i386 0:3.0.3-41.el5 xen-devel.i386 0:3.0.3-41.el5 xen-libs.i386 0:3.0.3-41.el5
Dependency Installed: SDL.i386 0:1.2.10-8.el5 bridge-utils.i386 0:1.1-2 dnsmasq.i386 0:2.39-2.el5 kernel-xen.i686 0:2.6.18-53.el5 libvirt.i386 0:0.2.3-9.el5 libvirt-python.i386 0:0.2.3-9.el5 python-virtinst.noarch 0:0.103.0-3.el5 Complete! [root@rhel5 ~]# |
系统会安装这些包:
Installing: xen-libs ####################### [ 1/10]
Installing: SDL ####################### [ 2/10]
Installing: dnsmasq ####################### [ 3/10]
Installing: bridge-utils ####################### [ 4/10]
Installing: kernel-xen ####################### [ 5/10]
Installing: xen-devel ####################### [ 6/10]
Installing: libvirt-python ####################### [ 7/10]
Installing: libvirt ####################### [ 8/10]
Installing: xen ####################### [ 9/10]
Installing: python-virtinst ####################### [10/10]
Installing: SDL ####################### [ 2/10]
Installing: dnsmasq ####################### [ 3/10]
Installing: bridge-utils ####################### [ 4/10]
Installing: kernel-xen ####################### [ 5/10]
Installing: xen-devel ####################### [ 6/10]
Installing: libvirt-python ####################### [ 7/10]
Installing: libvirt ####################### [ 8/10]
Installing: xen ####################### [ 9/10]
Installing: python-virtinst ####################### [10/10]
第二步:安装图形界面管理工具yum install “virt-manager*”
[root@rhel5 ~]#
yum install virt-manager*
Loading "security" plugin Loading "rhnplugin" plugin Loading "installonlyn" plugin This system is not registered with RHN. RHN support will be disabled. Setting up Install Process Setting up repositories Reading repository metadata in from local files Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. --> Downloading header for virt-manager to pack into transaction set. virt-manager-0.4.0-3.el5. 100% |=========================| 35 kB 00:00 --> Package virt-manager.i386 0:0.4.0-3.el5 set to be updated --> Running transaction check --> Processing Dependency: gnome-python2-gnomekeyring >= 2.15.4 for package: virt-manager --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. --> Downloading header for gnome-python2-gnomekeyring to pack into transaction set. gnome-python2-gnomekeyrin 100% |=========================| 3.5 kB 00:00 --> Package gnome-python2-gnomekeyring.i386 0:2.16.0-1.fc6 set to be updated --> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size ============================================================================= Installing: virt-manager i386 0.4.0-3.el5 VT 1.3 M Installing for dependencies: gnome-python2-gnomekeyring i386 2.16.0-1.fc6 Server 15 k
Transaction Summary
============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s)
Total download size: 1.3 M
Is this ok [y/N]: y Downloading Packages: (1/2): virt-manager-0.4.0 100% |=========================| 1.3 MB 00:00 (2/2): gnome-python2-gnom 100% |=========================| 15 kB 00:00 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: gnome-python2-gnomekeyring ######################### [1/2] Installing: virt-manager ######################### [2/2]
Installed: virt-manager.i386 0:0.4.0-3.el5
Dependency Installed: gnome-python2-gnomekeyring.i386 0:2.16.0-1.fc6 Complete! [root@rhel5 ~]# |
第三步:重新启动,选择带xen的内核
选择带xen的内核启动,刚才安装xen的时候,帮我们升级了内核,现在要用支持xen的内核启动
下面我们要安装虚拟机的源文件,我们用nfs提供,先挂载光盘,然后把光盘的内容拷贝到本地的一个目录中。
cd /misc/cd
cp -r * /var/ftp/pub (-r 递归拷贝)
光碟内容比较多,所有会花掉一些时间,我在做yum服务器的时候已经把这步做了,所以我们继续下一步
第四步:使用nfs共享刚才拷贝过来的文件夹
[root@rhel5 ~]#
vim /etc/exports
修改nfs配置文件,添加这样一行:
/var/ftp/pub/ 192.168.0.0/24(ro) ,前面是共享的目录,后面是可以访问的网络,ro是以只读方式共享,其他参数我们以后学习,nfs服务器的时候会讲到,写好后,保存退出。
重新启动nfs服务器:
service nfs restart
完成以后,使用命令
#showmount -e 查看nfs是否共享成功
NFS共享成功以后,我们就开始安装虚拟机了
图形界面安装XEN虚拟机
点击文件后选择新系统
输入你虚拟机的名字
上面是半虚拟化技术,下面是全虚拟化技术,我的CPU不支持全虚拟化,所以我们用半虚拟化
上面是选择安装介质的URL,下面是选择KICKSTART文件的位置,kickstart就是无人职守安装的配置文件,这里我们不用
然后下一步
我们先建立一个文件夹以存放虚拟机镜像。
虚拟机文件的存放位置,我们修改下,选择浏览。
下面文件大小,也就是虚拟机的硬盘大小 。allocate entire virtual disk now?就是马上分配虚拟空间,不要勾选,如果选择了,他会马上格式化文件大小的空间。
网卡设备选下面的
设置内存大小
配置的相关信息
点击结束进行安装
创建密钥环
下面的步骤就和本地安装一样了
命令行模式安装XEN虚拟机
输入
virt-install命令
按照提示分别输入虚拟机的名字、内存、存放路径等等信息
也可以选择启用图形支持,随便哈~~上面我选择的是不用图形支持哈,不过文字界面安装linux有时候会出现一些问题。比如挂载不了NFS,这个是因为网络的连接模式的原因,如果出现这种情况,建议使用图形界面。
按照平时安装的顺序一步一步的下去就好了
配置IP地址
提示要输入序列号
有安装过RHEL5经验的都熟悉这样的步骤哈~~~
安装过后就是XEN虚拟机的管理,大家在命令行输入#xm
系统就会把所有关于XEN的命令都列出来,前面是命令,后面是解释
常用的有以下命令
显示虚拟机运行状态:
xm list
开启虚拟系统: xm create <虚拟机名称>
使用文本方式连接虚拟系统: xm console <虚拟机名称>
关闭虚拟系统: xm shutdown <虚拟机名称> xm destroy <虚拟机名称>
重新启动虚拟系统: xm reboot <虚拟机名称>
开启虚拟系统: xm create <虚拟机名称>
使用文本方式连接虚拟系统: xm console <虚拟机名称>
关闭虚拟系统: xm shutdown <虚拟机名称> xm destroy <虚拟机名称>
重新启动虚拟系统: xm reboot <虚拟机名称>
X将虚拟系统当前状态保存到文件中:
xm save <虚拟机名称> <文件名>
恢复已保存的虚拟系统: xm restore <文件名>
暂停虚拟系统: xm pause <虚拟机名称>
恢复被暂停的虚拟系统: xm unpause <虚拟机名称>
恢复已保存的虚拟系统: xm restore <文件名>
暂停虚拟系统: xm pause <虚拟机名称>
恢复被暂停的虚拟系统: xm unpause <虚拟机名称>
#######################################################################