Chinaunix首页 | 论坛 | 博客
  • 博客访问: 325988
  • 博文数量: 104
  • 博客积分: 3025
  • 博客等级: 中校
  • 技术积分: 1150
  • 用 户 组: 普通用户
  • 注册时间: 2005-02-02 11:12
文章分类

全部博文(104)

文章存档

2013年(1)

2011年(2)

2010年(30)

2009年(29)

2008年(8)

2007年(15)

2006年(17)

2005年(2)

我的朋友

分类:

2010-07-22 18:29:45

目的: 无人值守安装虚拟机

部署版本:CentOS release 5.4 x86_64

实施:

服务器端

1.安装Cobbler安装包cobbler-1.0.3-1.el5.noarch.rpm 

wget http://blogimg.chinaunix.net/blog/upfile2/100816161630.gz

tar zxvf 100816161630.gz

rpm -ivh python-cheetah-2.0.1-1.el5.x86_64.rpm;rpm -ivh cobbler-1.0.3-1.el5.noarch.rpm


2.

cobbler check

tftp disable-->no
yum install yum-utils
/etc/cobbler/settings
   将next_server改为本机ip
   将server改为本机ip
service iptables stop
rm /etc/cobbler/sample.ks
rm /etc/cobbler/legacy.ks
rm /etc/cobbler/sample_end.ks
   直至cobbler check成功

3.

service httpd start

service cobblerd start



4.

wget http://install/sys/iso/CentOS/CentOS-5.4-x86_64-bin-DVD.iso
  mount -o loop CentOS-5.4-x86_64-bin-DVD.iso /data/centos


5.

cobbler import --mirror=/data/centos --name=Centos-5.4-x86_64


6.建立kickstart
  /etc/cobbler/kickstarts/S3APP0001.ks

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth
--useshadow --enablemd5
# System bootloader configuration
bootloader
--location=mbr
# Partition clearing information
clearpart
--all --initlabel
# Use text mode install
text
# Firewall configuration
firewall
--enabled
# Run the Setup Agent on first boot
firstboot
--disable
# System keyboard
keyboard us
# System language
lang en_US
# Use network installation
#url
--url=$tree
url
--url=http://192.168.0.254/cobbler/ks_mirror/Centos-5.4-x86_64/

#修改为你的IP
#
If any cobbler repo definitions were referenced in the kickstart profile, include them here.
#$yum_repo_stanza
# Network information
network
--bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot

#Root password
rootpw 123456
# SELinux configuration
selinux
--disabled
# Do
not configure the X Window System
skipx
# System timezone
#timezone America/New_York
timezone Asia/Shanghai
# Install OS instead
of upgrade
install
# Clear the Master Boot
Record
zerombr

# Magically figure
out how to partition this thing
SNIPPET
::partition_select
$kickstart_start

%packages

%post
$yum_config_stanza
$kickstart_done


7.

cobbler sync


8.

cobbler profile add --name=S3APP0001 --distro=Centos-5.4-xen-x86_64 --kickstart=/etc/cobbler/kickstarts/S3APP0001.ks --kopts='noipv6'--virt-path=/dev/domovg/S3APP0001 --virt-ram=2048 --virt-cpus=2 --virt-type=xenpv --virt-bridge=xenbr0


9. 

cobbler system add --name=S3APP0001 --profile=S3APP0001 --virt-path=/dev/domovg/S3APP0001 --mac=00:16:3E:1d:3d:65


10.确保dhcp的启动


客户端

前提:客户端已经安装好linux

1.看CPU是否支持虚拟化
半虚拟化硬件要求:
[root@linux ~]# cat /proc/cpuinfo | grep flags
flags : fpu tsc msr pae mce cx8 mtrr mca cmov pat pse36 mmx fxsr sse up

全虚拟化硬件要求:
INTEL系列CPU
[root@linux ~]# cat /proc/cpuinfo | grep flags
flags : fpu tsc msr pae mce cx8 apic mtrr mca cmov pat pse36 clflush dts
acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni
monitor ds_cpl vmx est tm2 cx16 xtpr lahf_lm
AMD系列CPU
[root@linux ~]# cat /proc/cpuinfo | grep flags
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt
rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic
cr8legacy 3dnowprefetch ts fid vid ttp tm stc 100mhzsteps

2.安装koan,在服务器端第一步的100729160917.zip文件里

rpm -ivh koan-1.2.5-1.el5.noarch.rpm


3.安装XEN

yum groupinstall virtualization


4.

修改grub.conf  将default 从1 改为 
reboot


5.

service libvirtd start



6.

koan --server=192.168.1.1 --system=S3APP0001 --virt --virt-name=S3APP0001



如果有问题,可以打开客户端机器的X界面,看虚拟机状态排除问题


记录


umount /dev/domovg/data
lvremove -f /dev/domovg/data


lvcreate -L 30G -n S2APP0001 domovg
lvcreate -L 30G -n S2APP0002 domovg
lvcreate -L 30G -n S2APP0003 domovg
lvcreate -l 1103 -n data domovg
mkfs.ext3 /dev/domovg/data
mount /dev/domovg/data /data

将/data/加入/etc/fstab,设为自动启动


yum groupinstall gnome-desktop

yum groupinstall virtualization



报错1:

[root@ts3web2 tmp]# koan --server=10.29.60.19 --system=S3APP2005 --virt --virt-name=S3APP2005
- reading URL:
install_tree:
libvirtd (pid 14829) is running...
downloading initrd initrd.img to /var/lib/xen/initrd.img
url=http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/initrd.img
- reading URL: http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/initrd.img
downloading kernel vmlinuz to /var/lib/xen/vmlinuz
url=http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/vmlinuz
- reading URL: http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/vmlinuz
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByUUID
libvir: Xen error : Domain not found: xenUnifiedDomainLookupByName
libvir: Xen Daemon error : POST operation failed: xend_post: error from xen daemon: (xend.err 'Error creating domain: I need 2097152 KiB, but dom0_min_mem is 262144 and shrinking to 262144 KiB would leave only 1641040 KiB free.')
libvirt.libvirtError
POST operation failed: xend_post: error from xen daemon: (xend.err 'Error creating domain: I need 2097152 KiB, but dom0_min_mem is 262144 and shrinking to 262144 KiB would leave only 1641040 KiB free.')
  File "/usr/lib/python2.4/site-packages/koan/app.py", line 165, in main
    k.run()
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 373, in run
    self.virt()
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 644, in virt
    return self.net_install(after_download)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 563, in net_install
    after_download(self, profile_data)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 642, in after_download
    self.virt_net_install(profile_data)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 920, in virt_net_install
    bridge = self.virt_bridge
   File "/usr/lib/python2.4/site-packages/koan/xencreate.py", line 165, in start_install
    guest.start_install()
   File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 541, in start_install
    return self._do_install(consolecb, meter, removeOld, wait)
   File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 633, in _do_install
    self.domain = self.conn.createLinux(install_xml, 0)
   File "/usr/lib64/python2.4/site-packages/libvirt.py", line 974, in createLinux
conn     if ret is None:raise libvirtError('virDomainCreateLinux() failed',=self)

表示内存不够

报错2:

[root@ts3web2 tmp]# koan --server=10.29.60.19 --system=S3APP2005 --virt --virt-name=S3APP2005
- reading URL:
install_tree:
libvirtd (pid 14829) is running...
downloading initrd initrd.img to /var/lib/xen/initrd.img
url=http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/initrd.img
- reading URL: http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/initrd.img
downloading kernel vmlinuz to /var/lib/xen/vmlinuz
url=http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/vmlinuz
- reading URL: http://10.29.60.19/cobbler/images/Centos-5.4-xen-x86_64/vmlinuz
exceptions.ValueError
Guest name 'S3APP2005' is already in use.
  File "/usr/lib/python2.4/site-packages/koan/app.py", line 165, in main
    k.run()
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 373, in run
    self.virt()
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 644, in virt
    return self.net_install(after_download)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 563, in net_install
    after_download(self, profile_data)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 642, in after_download
    self.virt_net_install(profile_data)
   File "/usr/lib/python2.4/site-packages/koan/app.py", line 920, in virt_net_install
    bridge = self.virt_bridge
   File "/usr/lib/python2.4/site-packages/koan/xencreate.py", line 104, in start_install
    guest.set_name(name)
   File "/usr/lib/python2.4/site-packages/virtinst/Guest.py", line 125, in set_name
    raise ValueError(_("Guest name '%s' is already in use.") % val)

表示配置文件已存在,需要删除配置文件先
阅读(2020) | 评论(0) | 转发(0) |
0

上一篇:about squid

下一篇:about redhat yum

给主人留下些什么吧!~~