zoukankan      html  css  js  c++  java
  • [原]Redhatel5_x86_64下Xen安装、配置、使用及出现的问题和解决方法

    Redhat-el5_x86_64下Xen安装、配置、使用及出现的问题和解决方法

    1、xen的配置及安装  

    1)首先安装kernel包:

    [root@localhost ~]#yum -y install kernel-xen.x86_64
    [root@localhost ~]#yum -y install xen-libs.x86_64

    2)接下来修改引导内核的配置文件/etc/grub.conf让系统引导xen这个内核

    安装好kernel-xen后在/etc/grub.conf文件将会出现以下内容
     # 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/hda
     default=1
     timeout=5
     splashimage=(hd0,0)/grub/splash.xpm.gz
     hiddenmenu
     title Red Hat Enterprise Linux Server (2.6.18-8.el5xen)
     root (hd0,0)
     kernel /xen.gz-2.6.18-8.el5
     module /vmlinuz-2.6.18-8.el5xen ro root=/dev/VolGroup00/LogVol00 rhgb quiet
     module /initrd-2.6.18-8.el5xen.img

    title Red Hat Enterprise Linux Server (2.6.18-8.el5)
     root (hd0,0)
     kernel /vmlinuz-2.6.18-8.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
     initrd /initrd-2.6.18-8.el5.img
     找到"default=1"改成"default=0"

    3)重启计算机

     [root@localhost ~]#reboot

    4)重启系统完成后,安装管理虚拟机包。我采用yum安装

     [root@localhost ~]#yum -y install libvirt.x86_64
     #安装xen服务
     [root@localhost ~]#yum -y install xen.x86_64
     [root@localhost ~]#yum -y install xen-devel.x86_64
     把xen服务加入到自启动脚本
     [root@localhost ~]#chkconfig --add xend
     [root@localhost ~]#chkconfig --level 345 xend on
     启动xen服务
     [root@localhost ~]#/etc/init.d/xend start
     Starting xend: [ OK ]

    2、配置启动一个虚拟机

    1)准备安装源

    Xen中安装domain的方式有多重,支持NFS文件服务或HTTP文件服务或FTP服务,下面配置是基于ftp服务的一个安装源。前提是准备好OS的iso镜像。放在一个目录中,如/home/liws/software/redhat-el5.iso。
    [root@localhost ~]#/etc/init.d/vsftpd start  #将ftp匿名用户开启
    [root@localhost ~]# mount -o loop /home/liws/software/redhat-el5.iso  /var/ftp/pub/ #挂载OS镜像到ftp下

    2)用xm命令行建立虚拟机:

    [root@localhost ~]# virt-install  --prompt(新版本的xen需要加参数 --prompt,有设置硬盘大小参数,旧版本没有这个参数
    What is the name of your virtual machine? domain1 #虚拟机的名字vm1
     How much RAM should be allocated (in megabytes)? 512 #为虚拟机分配内存512M 最低256M
     What would you like to use as the disk (file path)? /data/vmtest/domain1.img #虚拟OS的img存放位置
     How large would you like the disk (/data/vmtest/domain1.img) to be (in gigabytes)? 10 #虚拟OS的img文件大小
     What is the install URL? /var/ftp/pub #OS引导文件,这里只是让xen找到OS的引导,之后还有界面选择安装OS的具体设置。
     这里也可以直接输入:
     virt-install -n domain1 -r 512 --vcpus=1 -f /data/vmtest/domain1.img -s 10 -p -l /var/ftp/pub --nographics 创建并安装domain中的操作系统。参数意义如下:
    -n domain1 ,名称
    -r 512 ,分配512MB内存给domain1
    --vcpu=1 ,分配一个虚拟CPU
    -f /data/vmtest/domain1.img 指定虚拟磁盘文件为/data/vmtest/domain1.img
    -s 10 ,磁盘size是8GB
    -p ,使用para半虚拟化模式(因为本测试机CPU不支持VT技术)
    -l /var/ftp/pub ,指定安装镜像的位置
    --nographics ,不启动图形模式,只启动字符模式
    如果在中途出现什么问题,可以通过命令:xm console domain1进入控制台模式继续,看具体问题出在什么地方。

    3)下面就是安装OS的界面了,这里注意一点,在安装源的时候要选择FTP,可以设定具体的FTP服务器的IP和目录。

    OS的安装可以参考鸟哥的,上面更详细,这里不再赘述。http://linux.vbird.org/linux_enterprise/xen.php#other_inst

    3、启动一个虚拟机

       在命令行下执行xm create命令,即可启动domain。例如执行如下命令,即可将刚才安装好系统的domain引导起来。
     [root@localhost ~]# xm create domain1
     创建完domain之后,就可以通过以下命令进入到刚才安装好的OS里面了。
     [root@localhost ~]# xm console domain1
     关于xm命令读者可以通过命令:xm help来查看,也可以查找其他的资料。

    4、让domain随服务器启动而自动启动

     在服务器重启的时候,所有domain会自动的停止。当服务器完成重启后,domain还会继续保持关闭的状态,而不是自动启动。如果需要让domain自动启动,需要做如下操作,这里以domain1为例:
    [root@localhost ~]# ln -s /etc/xen/domain1 /etc/xen/auto/domain1
    这一步操作的作用是,将domain的配置文件用link链接到auto目录下。凡是在auto目录下的domain,都会随着服务器启动而自动启动。
     完毕后还要将xendomains设置为随机启动的后台服务。
    [root@localhost ~]# chkconfig --add xendomains
    现在重启服务器,就会发现名为domain1的domain也随着服务器启动而启动了。
     
     

    作者:yuandianlws 发表于2012-5-25 9:22:32 原文链接
    阅读:603 评论:0 查看评论
  • 相关阅读:
    java笔记前端部分
    java笔记数据库部分
    java笔记javaweb部分
    java笔记java部分
    JSON常用方法
    MYSQL索引
    Mysql查看执行计划参数解析(转载)
    MySQL中使用SHOW PROFILE命令分析性能的用法
    MySql查询
    DBeaver下载
  • 原文地址:https://www.cnblogs.com/yuandianliws/p/3568287.html
Copyright © 2011-2022 走看看