歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

利用oz制作RHEL系統鏡像

以前研究openstack,比較煩的就是制作鏡像和網絡這塊。

網絡: Havana版本之前的網絡這塊功能比較差,配置也相對復雜些,再加上自身基礎不好,所以理解起來相當困難。不過好在Havana版本中網絡這塊有了很大的改善,配置和界面都很友善。據說UOS的界面很華麗,期待……

制作鏡像:之前制作鏡像都是采用”先裝一次系統,做成模板,然後通過glance上傳“這個土方法,而且還要制作Rhel5/6、Centos5/6、Ubuntu、Windows Server 2003/2008等各種系統的模板,相對麻煩。

 

最近在研究H版的openstack過程中,發現以前制作鏡像的方法不好使,老是獲取不到分配的IP。無奈之下只好嘗試通過別的方法制作鏡像,於是就發現了oz這個工具,突然發現制作鏡像是如此easy。

下面以制作RHEL 6.3鏡像為例:

  • 首先,安裝oz工具:

yum install -y oz libguestfs-tools

  • 其次,創建一個TDL文件 6.3.tdl:

<template>
<name>rhel63_x86_64</name>
<description>RedHat 6.3 x86_64 template</description>
<os>
<name>RHEL-6</name>
<version>3</version>
<arch>x86_64</arch>
<rootpw>rootpasswd</rootpw>
<install type=’iso’>
<iso>file:///u01/rhel-server-6.3-x86_64-dvd.iso</iso>
</install>
</os>
<commands>
<command name=’console’>
sed -i ‘s/ rhgb//g’ /boot/grub/grub.conf
sed -i ‘s/ quiet//g’ /boot/grub/grub.conf
</command>
<command name=’update’>
sed -i ‘/^HWADDR/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i ‘/^UUID/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
echo -n > /etc/udev/rules.d/70-persistent-net.rules
echo -n > /lib/udev/rules.d/75-persistent-net-generator.rules
sed -i ‘/^SELINUX=/s/enforcing/disabled/’ /etc/selinux/config
</command>
</commands>
</template>

  • 通過oz-install生成鏡像(鏡像會生成在/var/lib/libvirt/images/目錄下)

oz-install -u -d3 6.3.tdl

  • 最後,通過glance上傳鏡像

glance add name=RHEL-6.3 is_public=true container_format=bare disk_format=raw < /var/lib/libvirt/images/rhel63_x86_64.dsk

 

其它系統TDL模板文件:

RHEL5.8:

<template>
<name>rhel58_x86_64</name>
<description>RedHat 5.8 x86_64 template</description>
<os>
<name>RHEL-5</name>
<version>U8</version>
<arch>x86_64</arch>
<rootpw>rootpasswd</rootpw>
<install type=’iso’>
<iso>file:///u01/rhel-server-5.8-x86_64-dvd.iso</iso>
</install>
</os>
<commands>
<command name=’update’>
sed -i ‘/^HWADDR/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i ‘/^SELINUX=/s/enforcing/disabled/’ /etc/selinux/config
</command>
</commands>
</template>

 RHEL6.4:

<template>
<name>rhel64_x86_64</name>
<description>RedHat 6.4 x86_64 template</description>
<os>
<name>RHEL-6</name>
<version>4</version>
<arch>x86_64</arch>
<rootpw>rootpasswd</rootpw>
<install type=’url’>
<url>http://rhn.uoregon.edu/pub/isos/full/RHEL-6.4/x86_64/</url>
</install>
</os>
<commands>
<command name=’console’>
sed -i ‘s/ rhgb//g’ /boot/grub/grub.conf
sed -i ‘s/ quiet//g’ /boot/grub/grub.conf
sed -i ‘s/ console=tty0 / serial=tty0 console=ttyS0,115200n8 /g’ /boot/grub/grub.conf
</command>
<command name=’update’>
sed -i ‘/^HWADDR/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i ‘/^UUID/d’ /etc/sysconfig/network-scripts/ifcfg-eth0
echo -n > /lib/udev/rules.d/75-persistent-net-generator.rules
sed -i ‘/^SELINUX=/s/enforcing/disabled/’ /etc/selinux/config
</command>
</commands>
</template>

參考文章:
https://access.redhat.com/site/documentation/en-US/Red_Hat_OpenStack/3/html/Installation_and_Configuration_Guide/Building_a_Custom_Disk_Image.html
https://github.com/rackerjoe/oz-image-build

 

Copyright © Linux教程網 All Rights Reserved