友情提示:
最新在研究squid、varnish、fastcgi_cache等缓存加速技术,有兴趣的朋友加我QQ 8431360

获取XEN guestOS的images文件

我们可以从http://stacklet.com/其实就是原来http://jailtime.org/站点找我们需要的xen image文件

在2009年的时候,jailtime.org发布了一个新闻

May 4th, 2009

The jailtime project has been relaunched with a new name and site: Stacklet

As part of the relaunch all of the distributions currently on jailtime have been upgraded to their latest versions. Also, all of the code for creating the images is now publically available – see http://stacklet.com/ for further details....

Jailtime will remain online but downloads will probably be turned off eventually as the transition to stacklet proceeds.

所以现在就访问http://stacklet.com/就可以了。

包括如下系统

  • 下面是一个站点提供的img文件的简单说明

    All files on this site are provided without guarantee or warranty. Use at your own risk.

    Each download is a bzipped tarball containing an image and cfg files:

    • a xen guest filesystem

    • sample xen configuration files to be used with xm create

    The naming convention of the download tarball is:

    <distribution>.<distro-version>.<created-date>.img.tar.bz2.

    For example centos.5-3.x86.20090423.img.tar.bz2 contains

    • centos.5-3.x86.img

    • centos.5-3.x86.xen3.cfg

    • centos.5-3.x86.xen3.pygrub.cfg(这个文件比较重要,如果用的是CentOS 5.3的虚拟化,就需要这个文件才可以启动guestOS。因为CentOS 5.3没有提供Xen-U的内核。)

    All of the packages installed in the image will be the latest versions available as of the created date, which is in yyyy-mm-dd format.

    Prerequisites

    1. Working installation of Xen version 3

    2. The xen daemon (xend) must be running

    3. Enough filesystem space to accomodate the uncompressed tarball (generally 1GB)

    4. Enough unallocated RAM to run the xen guest (generally 128MB)

    Default Configuration and Networking

    Each filesystem is configured to use dhcp. The *.xen.cfg also is also configured for dhcp. It is recommended that you first test the filesystem using dhcp if possible before attempting other networking parameters. Each download page has additional notes on networking that is appropriate for a particular distribution.

    The root login is root/password. It is highly recommened that you change the root password immediately.

    Installation

    You will need to uncompress the tarball to a local directory and edit the *.xen.cfg file to point to the uncompressed image and swap file.

    If all is well you will see the guest’s boot messages scrolling by.

    一些HOWTO文档

    HOWTO: Filesystems

    In the following howto’s, <image file> should be replaced with a reference to a specific .img file.

    How do I mount an image without booting it?

    • mkdir -p /mnt/loop

    • mount -o loop <image file> /mnt/loop/

    How do I resize an image file?

    First, make sure that the image file is not already mounted and is not already running as a xen guest. The following commands increase an image file to 2.5GB. Backup the image before attempting this.

    • dd if=/dev/zero of=<image file> bs=1M conv=notrunc count=1 seek=2500

    • losetup /dev/loop0 <image file>

    • e2fsck -f /dev/loop0

    • resize2fs /dev/loop0

    • e2fsck -f /dev/loop0

    • losetup -d /dev/loop0

    You may then boot or mount the image to confirm the increased size. The e2fsck checks in this howto are not strictly necessary.

    How do I move the contents of an img file to a regular partition?

    Mount the img file using the above howto. Assuming the destination partition is mounted at /mnt/dest, execute the following:

    • cp -a /mnt/loop/* /mnt/dest/

    You will then be able to boot the filesystem using the partition instead of the image file, which should provide better performance. You will need to update the *.xen.cfg file to reference the partition instead of the img file (the disk parameter will need to change, see the Xen Manual). Also, remember to unmount partitions or img files before booting a xen guest from them!

  • 评论:0 浏览:2007

    CentOS虚拟化服务的配置

    单位到了一台sun的x4450服务器,打算开学前部署好虚拟化服务,给每位带学生实训的老师一台虚拟的windows 2003 Server. 大约需要20台虚拟服务器

    服务器介绍
    点击在新窗口中浏览此图片


    硬件配置:

    CPU: 4颗 Intel(R) Xeon(R) CPU           X7460  @ 2.66GHz   (每颗6核心,供24核心)

    内存: 64G

    硬盘: 8块 Vendor: HITACHI   Model: H101414SCSUN146G  Rev: SA25

    虚拟方案

    用CentOS 5.3 64bit 作为DOM0,来管理整个虚拟化服务。然后采用hvm方式虚拟20台Windows server 2003。

    虚拟服务器配置:

    CPU:1颗

    内存:1G

    硬盘:30G

    整体结构如下
    点击在新窗口中浏览此图片


    在SunFire X4450的硬件上,安装Xen虚拟化服务。所有硬件由Xen内核管理,我们的CentOS 5.3 64bit操作系统跑在Xen内核上面,负责管理以后创建的DOM1到DOMN的多个虚拟服务器。

    虚拟化服务的安装

    这个就不具体写了,可以参考我前面的blog或者

    http://www.howtoforge.com/paravirtualization-with-xen-on-centos-5.3-x86_64-p2

    如果不安装图形界面,在用virt-install安装windows操作系统的时候,需要VNC服务。这样可以远程通过VNC客户端连接来安装,因为ssh的方式没有图形界面。

    如果安装了图形界面的CentOS,就很容易了。直接用图形界面的虚拟机管理程序安装即可。

    GUESTOS的配置

    由于每台虚拟服务器安装后,并没有开启远程服务,所以我们还是需要通过VNC连接登入虚拟服务器。在配置好IP和远程服务后,就可以使用远程桌面登陆了。

    在每台虚拟服务器的配置文件里,加入如下语句

    vnc = 2
    vncunused = 2
    vnclisten = "10.10.15.151"
    vncpasswd = "password"

    注意:password为登陆vnc的密码,根据实际情况设置。vnclisten设置的是主机CentOS的IP

    突破8台虚拟服务器的限制

    默认安装后,CentOS的max_loop最大值是8,这样我们默认只能启动8个虚拟服务器(不过半虚拟的linux好像不受这个影响)

    我们需要修改这个参数

    rmmod loop

    echo "options loop max_loop=64">/etc/modprobe.d/loop

    modprobe loop

    这样就可以了。

    配置网络

    我的服务器是有4块网卡 eth0、eth1、eth2、eth3

    我打算eth0 采用10.10.15.151 ip地址,其他网卡不设置IP地址并且将/etc/sysconfig/network-scripts/下对应的脚本文件修改如下

    ONBOOT=no

    这样可以让系统启动后,就eth0可以用来访问。其他网卡都没有对应ip地址

    其他网卡的作用是留给虚拟服务器用的。我们通过修改xen的配置文件,让eth0到eth1绑定到xenbr0到xenbr3上面。然后20台服务器,10台通过xenbr1访问网络,10台通过xenbr2访问

    在rc.local文件里,添加

    /etc/xen/scripts/new-bridge start

    new-bridge是我们自己写的脚本文件,为了创建xenbr0到xenbr3。xen系统默认就创建一个xenbr0

    new-bridge文件内容如下

    vi /etc/xen/scripts/new-bridge

    #######################################################################
    #!/bin/sh
    # Exit if anything goes wrong.
    set -e

    # First arg is the operation.
    OP=$1
    shift

    script=/etc/xen/scripts/network-bridge.xen

    case ${OP} in
    start)
              $script start vifnum=0 bridge=xenbr0 netdev=eth0
              $script start vifnum=1 bridge=xenbr1 netdev=eth1
              $script start vifnum=2 bridge=xenbr2 netdev=eth2
              $script start vifnum=3 bridge=xenbr3 netdev=eth3
    #         $script start vifnum=2 bridge=xenbri netdev=dummy0
              ;;

    stop)
              $script stop vifnum=0 bridge=xenbr0 netdev=eth0
              $script stop vifnum=1 bridge=xenbr1 netdev=eth1
              $script stop vifnum=2 bridge=xenbr2 netdev=eth2
              $script stop vifnum=3 bridge=xenbr3 netdev=eth3
    #         $script stop vifnum=2 bridge=xenbri netdev=dummy0
              ;;

    status)
              $script status vifnum=0 bridge=xenbr0 netdev=eth0
              $script status vifnum=1 bridge=xenbr1 netdev=eth1
              $script status vifnum=2 bridge=xenbr2 netdev=eth2
              $script status vifnum=3 bridge=xenbr3 netdev=eth3
    #         $script status vifnum=2 bridge=xenbri netdev=dummy0
             ;;

    *)
              echo 'Unknown command: ' ${OP}
              echo 'Valid commands are: start, stop, status'
              exit 1
    esac
    ########################################################################

    安装xen-shell,让用户自己管理自己的虚拟服务器

    具体安装步骤就不写了,参考我前面的文章吧

    安装和使用xen-shell
    或者
    http://www.xen-tools.org/software/xen-shell/install.html

    注意

    安装这个,需要screen这个软件,可以通过yum install screen安装

    再有就是需要/etc/xen/下面的虚拟机配置文件有对应的权限

    安装后,用root用户,直接输入xen-shell看看能不能进入,如果报错,根据提示修改。

    全部安装完成后,让我们看看20台虚拟服务器跑起来的效果
    点击在新窗口中浏览此图片

    点击在新窗口中浏览此图片


    再来看看网络的使用情况
    点击在新窗口中浏览此图片


    通过上面的brctl show可以清楚的看到,虚拟服务器的网卡,都放到了xenbr1和xenbr2下面了。

    再来看看vnc登陆的界面,注意VNC登陆后,不能直接用键盘的Ctrl+Alt+Del登陆,我们可以通过右键点窗口来选择Send Ctrl+Alt+Del来实现发送这三个按键消息。
    点击在新窗口中浏览此图片


    配置好虚拟服务器的IP和远程桌面后,我们就可以采用远程桌面连接了。



    用户自己管理自己的服务器

    其实有了远程桌面,用户就可以通过这个登陆服务器,重启和修改配置了。但是如果关机以后,就没有办法开机了。

    我们安装xen-shell就能实现用户自己通过用户名和密码登陆命令行格式的界面来启动服务器。

    首先我们要给我们每台虚拟服务器建立一个CentOS系统上的用户,让后按照Xen-shell的要求配置,这个不具体介绍了,参考

    安装和使用xen-shell
    或者
    http://www.xen-tools.org/software/xen-shell/install.html

    以后用户就可以通过putty登陆到自己的虚拟服务器管理命令行了。



    xen-shell可以让用户自己启动、重启、关闭虚拟服务器,还可以查看虚拟服务器的状态、运行时间等。

    如果在用户对应目录下编写好image.sh文件,还可以让用户自己rebuild操作系统。

    有了这个,基本管理员告诉用户他的xen-shell用户,虚拟服务器的ip就ok了。其他的用户自己都可以管理了。

    其他问题

    如何让guestos随主系统自动启动,这个可以参考xen文档。

    如何克隆guestos系统,这个可以参考virt-clone

    如何安装多个linxu guest系统,这个可以参考获取XEN guestOS的images文件

    整个安装断断续续弄了大约2周,目前总算ok了。

    评论:1 浏览:4770

    我的网站开通了,www.xinlogs.com.

    以前一直在断断续续的写Blog,开始放在百度的空间。网址http://hi.baidu.com/babodx
    后来在09年7月,觉得http://hi.baidu.com/babodx空间的功能太少了,就搬家到了http://babodx.spaces.live.com并且注册了xinlogs.com域名。
    后来就一直关注VPS空间,觉得这个很好,相当于自己有了一台虚拟的服务器,完全可以自己在上面配置各种服务。
    于是在2009年12月18日,我终于决定购买了rashost.com的1款128M内存的VPS,位置在美国的洛杉矶机房。
    价格还算便宜1个月68元。
    rashost的有点就是不限制流量,而且CPU采用intel至强的。速度也不错
    我选择了CentOS 5.3系统

    CPU信息model name      : Intel(R) Xeon(R) CPU           X3220  @ 2.40GHz
    内存信息
                 total       used       free     shared    buffers     cached
    Mem:           128        119          8          0          9         67
    -/+ buffers/cache:         42         86
    Swap:          255          0        255


    我的网站采用Nginx+PHP+MySQL+Bo-Blog架设,参考了www.s135.com上的优化方法。

    后面剩下的工作就是如何将以前blog的文章搬家够来了。。。估计够折腾一阵子的。

    评论:0 浏览:8301

    © 2012 鑫的方向
    iDream theme by Templates Next | Powered by Emlog