#####################################################
##如有转载,请务必保留本文链接及版权信息
##欢迎广大运维同仁一起交流linux/unix网站运维技术!
##QQ:335623998
##E-mail:335623998@qq.com
##博客: http://dreamway.blog.51cto.com/
##weibo:http://weibo.com/zhaixiangpan
#####################################################

《Cobbler部署指南》系列

1、《Cobbler部署指南之安装篇》http://dreamway.blog.51cto.com/blog/1281816/1166589

2、《Cobbler部署指南之配置管理篇[上文]》http://dreamway.blog.51cto.com/blog/1281816/1166921

3、《Cobbler部署指南之配置管理篇[下文]》http://dreamway.blog.51cto.com/blog/1281816/1166932

4、《Cobbler部署指南之yum仓库配置管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166936

5、《Cobbler部署指南之Cobbler安装操作系统篇》http://dreamway.blog.51cto.com/blog/1281816/1166947

6、《Cobbler部署指南之安装虚拟化Xen系统篇》http://dreamway.blog.51cto.com/blog/1281816/1166950

7、《Cobbler部署指南之电源管理篇》http://dreamway.blog.51cto.com/blog/1281816/1166957

8、《Cobbler部署指南之FAQ处理篇》http://dreamway.blog.51cto.com/blog/1281816/1167078

7.5 安装Xen 宿主机

Cobbler PXE菜单里没有关于Xen虚拟机的系统版本,导入CentOS5.8系统镜像时,已经生成一个关于Xendistrosprofiles centos5.8-xen-x86_64,因为Cobbler知道它不可能PXE引导物理硬件。

如果你想安装Xen 宿主机,需要在安装脚本ks文件%packages部分添加xen包名 "kernel-xen"、“xen”。当然这样似乎不太方便,你可以使用命令“cobbler import”再导入一个关于xenserver宿主机的配置。

配置好ks文件,安装方法同步骤7.3

7.6 安装Xen虚拟机

7.6.1 Xen宿主机安装koan

 

7.6.2 查看关于Xen宿主机的配置信息

koan --server=172.17.10.14 --list=profiles

- looking for Cobbler at http://172.17.10.14/cobbler_api

centos5.8-xen-x86_64

centos6.4-x86_64

centos5.8-x86_64

centos6.3-x86_6

 

koan --server=172.17.10.14 --display --profile=centos5.8-xen-x86_64      

- looking for Cobbler at http://172.17.10.14:80/cobbler_api

- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64

install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64

                name  : centos5.8-xen-x86_64

              distro  : centos5.8-xen-x86_64

           kickstart  : http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64

             ks_meta  : tree=http://@@http_server@@/cblr/links/centos5.8-xen-x86_64

        install_tree  : http://172.17.10.14/cblr/links/centos5.8-xen-x86_64

              kernel  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/images/xen/vmlinuz

              initrd  : /var/www/cobbler/ks_mirror/centos5.8-x86_64/images/xen/initrd.img

      kernel_options  : ks=http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64 ksdevice=link kssendmac lang= text

               repos  :

            virt_ram  : 512

    virt_disk_driver  : raw

           virt_type  : xenpv

           virt_path  :

      virt_auto_boot  : 0

7.6.3 安装Xen虚拟机

koan --server=172.17.10.14 --virt-name=testvm   --virt --profile=centos5.8-xen-x86_64

- looking for Cobbler at http://172.17.10.14/cobbler_api

- reading URL: http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64

install_tree: http://172.17.10.14/cblr/links/centos5.8-xen-x86_64

libvirtd (pid  2749) is running...

downloading initrd initrd.img to /var/lib/xen/initrd.img

url=http://172.17.10.14/cobbler/images/centos5.8-xen-x86_64/initrd.img

- reading URL: http://172.17.10.14/cobbler/images/centos5.8-xen-x86_64/initrd.img

downloading kernel vmlinuz to /var/lib/xen/vmlinuz

url=http://172.17.10.14/cobbler/images/centos5.8-xen-x86_64/vmlinuz

- reading URL: http://172.17.10.14/cobbler/images/centos5.8-xen-x86_64/vmlinuz

Wed, 27 Mar 2013 16:12:17 DEBUG    No conn passed to Guest, opening URI 'None'

libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName

libvir: Xen error : Domain not found: xenUnifiedDomainLookupByUUID

libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName

Wed, 27 Mar 2013 16:12:17 DEBUG    Creating guest from:

<domain type='xen'>

  <name>testvm</name>

  <currentMemory>524288</currentMemory>

  <memory>524288</memory>

  <uuid>b0dee8f5-284b-1622-6191-2443ea10cc1c</uuid>

  <os>

    <type>linux</type>

    <kernel>/var/lib/xen/vmlinuz</kernel>

    <initrd>/var/lib/xen/initrd.img</initrd>

    <cmdline>ks=http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64 ksdevice=link kssendmac lang= text </cmdline>

  </os>

  <on_poweroff>destroy</on_poweroff>

  <on_reboot>destroy</on_reboot>

  <on_crash>destroy</on_crash>

  <vcpu>1</vcpu>

  <devices>

    <disk type='file' device='disk'>

      <source file='/var/lib/xen/images/testvm-disk0'/>

      <target dev='xvda' bus='xen'/>

    </disk>

    <interface type='bridge'>

      <source bridge='xenbr0'/>

      <mac address='00:16:3e:28:12:79'/>

    </interface>

    <input type='mouse' bus='xen'/>

    <graphics type='vnc' port='-1' keymap='en-us'/>

  </devices>

</domain>

 

Wed, 27 Mar 2013 16:12:18 DEBUG    Created guest, looking to see if it is running

Wed, 27 Mar 2013 16:12:18 DEBUG    Saving XML boot config:

<domain type='xen'>

  <name>testvm</name>

  <currentMemory>524288</currentMemory>

  <memory>524288</memory>

  <uuid>b0dee8f5-284b-1622-6191-2443ea10cc1c</uuid>

  <bootloader>/usr/bin/pygrub</bootloader>

  <on_poweroff>destroy</on_poweroff>

  <on_reboot>restart</on_reboot>

  <on_crash>restart</on_crash>

  <vcpu>1</vcpu>

  <devices>

    <disk type='file' device='disk'>

      <source file='/var/lib/xen/images/testvm-disk0'/>

      <target dev='xvda' bus='xen'/>

    </disk>

    <interface type='bridge'>

      <source bridge='xenbr0'/>

      <mac address='00:16:3e:28:12:79'/>

    </interface>

    <input type='mouse' bus='xen'/>

    <graphics type='vnc' port='-1' keymap='en-us'/>

  </devices>

</domain>

 

use virt-manager or reconnect with virsh console testvm

7.6.4 列出虚拟机列表

xm list

Name                                      ID Mem(MiB) VCPUs State   Time(s)

Domain-0                                   0     7494     4 r-----     79.0

testvm                                     1      512     1 r-----     86.5

7.6.5 打开控制台管理虚拟机

xm console 1

或者

xm console testvm

Bootdata ok (command line is  ks=http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64 ksdevice=link kssendmac lang= text )

Linux version 2.6.18-308.el5xen (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Tue Feb 21 20:47:10 EST 2012

BIOS-provided physical RAM map:

 Xen: 0000000000000000 - 0000000020800000 (usable)

No mptable found.

Built 1 zonelists.  Total pages: 129529

Kernel command line:  ks=http://172.17.10.14/cblr/svc/op/ks/profile/centos5.8-xen-x86_64 ksdevice=link kssendmac lang= text

Initializing CPU#0

…………略…………

Write protecting the kernel read-only data: 503k

Restarting system.

默认虚拟机配置文件在目录/etc/xen

 

7.6.6 启动虚拟机

xm create -c testvm

 

 

 

SecureCRT显示的启动、登录内容如下:

pyGRUB  version 0.6

 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿

 ³ CentOS (2.6.18-308.el5xen)                                             ³

 ³                                                                        ³

 ³                                                                        ³

 ³                                                                        ³

 ³                                                                        ³

 ³                                                                        ³

 ³                                                                        ³

 ³                                                                        ³

 ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ

     Use the ˜ and ™ keys to select which entry is highlighted.

     Press enter to boot the selected OS, 'e' to edit the

     commands before booting, 'a' to modify the kernel arguments

     before booting, or 'c' for a command line.

 

………虚拟机启动过程略……………

登录界面

CentOS release 5.8 (Final)

Kernel 2.6.18-308.el5xen on an x86_64

 

host-d-115.sys.hexun login: root

Password:

查看虚拟机主机名

[root@host-d-115 ~]# hostname

host-d-115.sys.hexun

查看ip

[root@host-d-115 ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:16:3E:28:12:79 

          inet addr:172.17.188.115  Bcast:172.17.255.255  Mask:255.255.0.0

          inet6 addr: fe80::216:3eff:fe28:1279/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:325 errors:0 dropped:0 overruns:0 frame:0

          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:25014 (24.4 KiB)  TX bytes:1298 (1.2 KiB)

到此Xen虚拟机已经通过Cobbler安装完毕。

 

请看《Cobbler部署指南》系列续文

《Cobbler部署指南》系列文档下载:http://down.51cto.com/data/745895