OZ工具安装使用

来源:互联网 发布:努尔哈赤知乎 编辑:程序博客网 时间:2024/06/07 06:30
http://www.chenshake.com/oz-making-centos-mirror/ 
http://www.iyunv.com/thread-71346-1-1.html 

对于Openstack的镜像来说,需要在image里安装cloud init,这样才能注入密钥,网络的设置,也是需要cloud init。
做镜像的步骤,比较繁琐,其实就是一个kvm的image,Oz这个工具,可以很方便让你定制各种操作系统的image,功能还是很强大的,Oz开发和更新还是非常频繁,非常值得关注的一个软件
目前EPEL源已经有Oz的安装包,更新还是非常及时,和开发同步,并且Redhat也是推荐使用这个工具来创建镜像。由于Oz需要使用网络来自动化创建镜像,所以建议别在Openstack的环境下进行使用,建议采用一台干净的机器来做。

准备centos7ISO创建一个而虚机,干净的虚机
操作记录:
1、安装epel源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@localhost yum.repos.d]# 
[root@localhost yum.repos.d]# yum install epel-release
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-CR.repo  CentOS-Debuginfo.repo  CentOS-fasttrack.repo  CentOS-Media.repo  CentOS-Sources.repo  CentOS-Vault.repo  epel.repo  epel-testing.repo

2、安装oz工具
[root@localhost yum.repos.d]# yum install -y libguestfs-tools
[root@localhost yum.repos.d]# yum install oz
oz安装没有成功,所以用下载的RPM包进项安装
[root@localhost yum.repos.d]# yum install python-libguestfs 
[root@localhost yum.repos.d]# yum install python-lxml
[root@localhost yum.repos.d]# yum install libvirt-python
[root@localhost yum.repos.d]# yum install libvirt
root@localhost yum.repos.d]# yum install m2crypto
首先得安装以上依赖包
[root@localhost yum.repos.d]# rpm -ivh /root/oz-0.15.0-1.el7.noarch.rpm

3、查看安装结果
[root@localhost yum.repos.d]# ls /etc/oz/
id_rsa-icicle-gen  id_rsa-icicle-gen.pub  oz.cfg
[root@localhost yum.repos.d]# find / -name oz
/etc/oz
/var/lib/oz

/usr/lib/python2.7/site-packages/oz

重启机器后会看见两个网卡信息virbr0  和 virbr0-nic ,说明oz工具安装成功了!


4、/etc/oz/oz.cfg   初始内容
[paths]
output_dir = /var/lib/libvirt/images
data_dir = /var/lib/oz
screenshot_dir = /var/lib/oz/screenshots
# sshprivkey = /etc/oz/id_rsa-icicle-gen


[libvirt]
uri = qemu:///system
image_type = raw
# type = kvm
# bridge_name = virbr0
# cpus = 1
# memory = 1024


[cache]
original_media = yes
modified_media = no
jeos = no


[icicle]
safe_generation = no



5、配置文件说明
利用oz自动床架镜像需要两个配置文件*.tdl  *.ks
------------------*.tdl------xml文件---------确定ISO文件来源--------
创建tdl文件更多参考例子:https://github.com/rcbops/oz-image-build/tree/master/templates 
从tdl文件安装支持两种格式:一种是iso,另一种是url,它们之间的差异是:采用iso类型时oz需要能够获取源镜像文件;URL类型则是从远程服务器(如cobbler服务器上)获取iso解压后的文件


6、运用命令

[root@localhost oz_cfg]# oz-install -p -u -d3 -a rhel6.5.ks rhel6.5.tdl


7、配置文件内容

[root@localhost oz_cfg]# cat centos7.ks
install
text
keyboard us
lang en_US.UTF-8
skipx
network --device eth0 --bootproto dhcp
rootpw %teamsun%
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200"

zerombr
clearpart --all --initlabel
autopart --type=lvm

reboot

%packages
openssh-clients
cloud-init
@core

%end



[root@localhost oz_cfg]# cat centos7.tdl
<template>
   <name>centos_7_x86_64</name>
   <description>CentOS 7 x86_64 template</description>
   <os>
      <name>CentOS-7</name>
      <version>5</version>
      <arch>x86_64</arch>
      <install type='iso'>
         <iso>file:////opt/oz_iso/CentOS-7-x86_64-Minimal-1511.iso</iso>
      </install>
   </os>
  <disk>
    <size>10</size>
  </disk>
</template>



0 0
原创粉丝点击