设为首页 收藏本站
查看: 1391|回复: 0

[经验分享] Xen 安装图解教程

[复制链接]

尚未签到

发表于 2015-10-12 08:47:31 | 显示全部楼层 |阅读模式
Xen 是一个开放源代码虚拟机监视器,由剑桥大学开发。它打算在单个计算机上运行多达100个满特征的操作系统。操作系统必须进行显式地修改(“移植”)以在Xen上运行(但是提供对用户应用的兼容性)。这使得Xen无需特殊硬件支持,就能达到高性能的虚拟化。

一,安装内核及图形管理器
yum -y install xen kernel-xen virt-manager
vim /boot/grub/grub.conf       //修改第一启动
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5xen)
        root (hd0,0)
        kernel /xen.gz-2.6.18-194.el5
        module /vmlinuz-2.6.18-194.el5xen ro root=LABEL=/ rhgb quiet
        module /initrd-2.6.18-194.el5xen.img
远程需要安装vnc
yum -y install vnc*
在终端shell中运行命令vncpasswd,添加客户端访问时使用的密码。
service vncserver start
在终端shell中运行命令vncserver, 此时会在$HOME/生成一个隐藏文件夹.vnc
进入cd 进入.vnc目录,编辑xstartup文件
取消这两行注释
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
注释掉#twm &
在最后一行添加gnome-session &
service vncserver restart
重启计算机,uname -r 查看是否已经支持
[iyunv@localhost network-scripts]# uname -r
2.6.18-194.el5xen
virt-install -n vm03 -f /data/vm02.img -s 4 -r 128 nographics -l http://192.168.152.129/CentOS








二、在CentOS5.8_x64位系统上安装Xen虚拟机
1.查看CPU是否支持完全虚拟化和半虚拟化


viewsourceprint?
1.[iyunv@Vmware5~]#cat /proc/cpuinfo | grep flags
2.flags          : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up nonstop_tsc arat pni ssse3 cx16 sse4_1 sse4_2 popcnt lahf_lm
注意:确保CPU支持xen虚拟化。半虚拟化需要pae,全虚拟化需要intel VT或者AMD PT的支持、包含pae,那么就支持半虚拟化。如果包含vmx(intel)或者svm(AMD),那么就支持全虚拟化。
2.查看系统和内核版本信息


viewsourceprint?
1.[iyunv@Vmware5~]#uname -a
2.<ahref=&quot;http://www.it165.net/os/oslin/&quot; target=&quot;_blank&quot; class=&quot;keylink&quot;>Linux</a>Vmware5 2.6.18-308.el5 #1SMP Tue Feb 21 20:06:06 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
3.[iyunv@Vmware5~]#lsb_release -a
4.LSBVersion:    :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
5.DistributorID: CentOS
6.Description:   CentOS release 5.8 (Final)
7.Release:       5.8
8.Codename:      Final
viewsourceprint?
1.3.查看下是否已经安装xen软件包
2.[iyunv@Vmware5~]#rpm -qa | grep xen
3.[iyunv@Vmware5~]#
4.安装xen kernel-xen两个包,查看下是否安装成功

viewsourceprint?
1.[iyunv@Vmware5~]#yum install -y xen kernel-xen
2.[iyunv@Vmware5~]#rpm -qa | grep xen
3.xen-libs-3.0.3-142.el5_9.3
4.kernel-xen-2.6.18-348.18.1.el5
5.xen-3.0.3-142.el5_9.3
此时,再查看下boot目录下生成了几个带xen的文件

viewsourceprint?
01.[iyunv@Vmware5~]#ls /boot/
02.config-2.6.18-308.el5             symvers-2.6.18-348.18.1.el5xen.gz
03.config-2.6.18-348.18.1.el5xen     System.map-2.6.18-308.el5
04.grub                              System.map-2.6.18-348.18.1.el5xen
05.initrd-2.6.18-308.el5.img         vmlinuz-2.6.18-308.el5
06.initrd-2.6.18-348.18.1.el5xen.img vmlinuz-2.6.18-348.18.1.el5xen
07.lost&#43;found                        xen.gz-2.6.18-348.18.1.el5
08.message                           xen-syms-2.6.18-348.18.1.el5
09.symvers-2.6.18-308.el5.gz
5.修改XENlinux的GRUB配置

viewsourceprint?
01.(1)修改GRUB引导文件
02.[iyunv@Vmware5~]#more /boot/grub/grub.conf
03.#grub.conf generated by anaconda
04.#
05.#Note that you do not have to rerun grub after making changes to this file
06.#NOTICE:  You have a /boot partition.  This means that
07.#         all kernel and initrd paths are relative to /boot/, eg.
08.#         root (hd0,0)
09.#         kernel /vmlinuz-version ro root=/dev/sda5
10.#         initrd /initrd-version.img
11.#boot=/dev/sda
12.default=0
13.timeout=5
14.splashimage=(hd0,0)/grub/splash.xpm.gz
15.hiddenmenu
16.pass<ahref=&quot;http://www.it165.net/edu/ebg/&quot; target=&quot;_blank&quot; class=&quot;keylink&quot;>word</a>--md5 $1$NGwpqBcK$qw1kGlKiVS2XXgwiIWW/C0
17.titleCentOS (2.6.18-348.18.1.el5xen)
18.root(hd0,0)
19.kernel/xen.gz-2.6.18-348.18.1.el5
20.module/vmlinuz-2.6.18-348.18.1.el5xen ro root=LABEL=/ rhgb quiet
21.module/initrd-2.6.18-348.18.1.el5xen.img
22.titleCentOS (2.6.18-308.el5)
23.root(hd0,0)
24.kernel/vmlinuz-2.6.18-308.el5 ro root=LABEL=/ rhgb quiet
25.initrd/initrd-2.6.18-308.el5.img
26.把原始文件的default=1修改成default=0
27.然后reboot重启服务器
重启完毕后,再查看下系统版本

viewsourceprint?
1.[iyunv@Vmware5~]#uname -a
2.LinuxVmware5 2.6.18-348.18.1.el5xen #1SMP Thu Sep 26 15:42:15 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
从显示的版本中可以看出,内核版本中出现了xen字样
6.安装图形管理工具和图形终端的两个软件包:virt-manager和virt-viewer


viewsourceprint?
1.[iyunv@Vmware5~]#yum install -y virt-manager
2.[iyunv@Vmware5~]#yum install -y virt-viewer
7.创建Xen虚拟系统安装树
Xen虚拟机半虚拟环境中安装Linux虚拟系统时需要使用系统的安装树。安装树是一个包含所有系统安装文件及相关程序的目录,这个目录可以是FTP、httpd或者是NFS等方式提供给Xen虚拟机用于系统的安装
这里为了方便,就用httpd,安装apache服务。


viewsourceprint?
1.[iyunv@Vmware5~]#yum install -y httpd
8.在apache的默认网站根目录下,创建centos目录

viewsourceprint?
1.[iyunv@Vmware5~]#mkdir /var/www/html/centos
9.mount挂载5.8的镜像


viewsourceprint?
01.[iyunv@Vmware5~]#mount -o loop /dev/cdrom /var/www/html/centos
02.[iyunv@Vmware5~]#df -h
03.Filesystem           Size  Used Avail Use% Mounted on
04./dev/sda5            7.4G  3.1G  3.9G  44% /
05./dev/sda2            2.0G   36M  1.9G   2% /home
06./dev/sda1            190M   20M  161M  11% /boot
07.tmpfs                432M     0  432M   0% /dev/shm
08.none                 432M  104K  432M   1% /var/lib/xenstored
09./dev/hdc             4.3G  4.3G     0 100% /var/www/html/centos
10.关闭iptables和selinux,并且启动httpd服务。

viewsourceprint?
01.[iyunv@Vmware5~]#/etc/init.d/iptables stop
02.Flushingfirewall rules:                                   [  OK  ]
03.Settingchains to policy ACCEPT: nat filter                [  OK  ]
04.Unloadingiptables modules:                                [  OK  ]
05.[iyunv@Vmware5~]#setenforce 0
06.setenforce:SELinux is disabled
07.[iyunv@Vmware5~]#/etc/init.d/httpd start
08.Startinghttpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
09.[ OK  ]
11.安装VNC-server服务,设置VNC-server密码。


viewsourceprint?
1.[iyunv@Vmware5~]#rpm -qa | grep vnc-server
2.vnc-server-4.1.2-14.el5_6.6
3.[iyunv@Vmware5~]#vncpasswd
4.Pass<ahref=&quot;http://www.it165.net/edu/ebg/&quot; target=&quot;_blank&quot; class=&quot;keylink&quot;>word</a>:
5.Verify:
6.配置VNCserver密码为123.com
12.修改下VNCserver的账号和端口,以及分辨率大小。

viewsourceprint?
1.[iyunv@Vmware5~]#tail -2 /etc/sysconfig/vncservers
2.VNCSERVERS=&quot;2:root&quot;
3.VNCSERVERARGS[2]=&quot;-geometry1280x720 -alwaysshared -depth 24&quot;.
13.重启VNCserver.

viewsourceprint?
1.[iyunv@Vmware5~]#/etc/init.d/vncserver start
2.StartingVNC server: 2:root xauth:  creating new authority file /root/.Xauthority
3.New'Vmware5:2 (root)' desktop is Vmware5:2
4.Creatingdefault startup script /root/.vnc/xstartup
5.Startingapplications specified in /root/.vnc/xstartup
6.Log file is/root/.vnc/Vmware5:2.log
7.[ OK  ]
14.为了避免VNCserver链接的时候,窗口出现灰色,需要取消~/.vnc/xstartup这个文件的两行注释。

viewsourceprint?
1.[iyunv@Vmware5~]#vim ~/.vnc/xstartup
2.unset SESSION_MANAGER
3.exec /etc/X11/xinit/xinitrc
4.这两行的注释去掉,保存退出。
重启VNCserver即可连接,安装Xen啦。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-125626-1-1.html 上篇帖子: OpenSolaris发布基于build66的Xen版本 下篇帖子: fc 8 安装xen
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表