首页 > 代码库 > OpenStack制作CentOS6.7镜像

OpenStack制作CentOS6.7镜像

1.下载镜像

直接访问官方镜像地址下载,注意选择中国的镜像源,相对国外镜像下载速率比较快,进入后选择版本为6.7,在isos目录下下载x86_64Minimal镜像.

2.创建虚拟机

首先需要创建一个qcow2格式镜像文件,用于作为虚拟机的磁盘,大小20G.

root@UKVM-IMG:/var/lib/libvirt/images# qemu-img create -f qcow2centos-6.7.qcow2 20G

Formatting ‘centos-6.7.qcow2‘, fmt=qcow2 size=21474836480 encryption=offcluster_size=65536 lazy_refcounts=off refcount_bits=16

快速创建并启动虚拟机:

root@UKVM-IMG:/var/lib/libvirt/images# virt-install --virt-type kvm --namecentos-6.7 --ram 1024   --diskcentos-6.7.qcow2,format=qcow2   --networknetwork=default   --graphicsvnc,listen=0.0.0.0 --noautoconsole  --os-type=linux --os-variant=rhel6  --cdrom=CentOS-6.7-x86_64-minimal.iso

 

Starting install...

Creating domain...                                                                    |    0 B  00:00:00    

Domain installation still in progress. You can reconnect to

the console to complete the installation process.

启动完成后,使用vnc client连接,可以直接使用virt-manager或者virt-viewer直接连接。

3. 安装OS

进入虚拟机控制台可以看到Centos的启动菜单,选择Install or upgrade an existing system,继续选择语言,选择键盘格局,选择Basic Storage Devices,开启网络,设置主机名为默认,设置时区Asia/Shanghai,设置root密码,选择“Create Custom Layout”,只需要一个根分区即可,不需要swap分区,文件系统选择ext4,存储驱动选择Virtio Block Device,如图:

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

完成安装配置工作,最后点击右下角的reboot重启退出虚拟机.

4. 配置OS

安装好系统后,还需要进行配置才能作为glance镜像使用,启动虚拟机:

root@UKVM-IMG:~# virsh list --all

 Id    Name                           State

----------------------------------------------------

 -     centos-6.7                     shut off

 -     centos7.2.1511-L               shut off

 -     centos72-L                     shut off

 

root@UKVM-IMG:~# virsh start centos-6.7

Domain centos-6.7 started

4.1 配置yum仓库

 

[root@localhost ~]# cd /etc/yum.repos.d/

[root@localhost yum.repos.d]# ls

CentOS-Base.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Vault.repo

[root@localhost yum.repos.d]# rm CentOS-Debuginfo.repo

rm: remove regular file `CentOS-Debuginfo.repo‘? y

[root@localhost yum.repos.d]# rm CentOS-fasttrack.repo

rm: remove regular file `CentOS-fasttrack.repo‘? y

[root@localhost yum.repos.d]# rm CentOS-Media.repo

rm: remove regular file `CentOS-Media.repo‘? y

[root@localhost yum.repos.d]# rm CentOS-Vault.repo

rm: remove regular file `CentOS-Vault.repo‘? y

[root@localhost yum.repos.d]# ls

CentOS-Base.repo

[root@localhost yum.repos.d]# mv CentOS-Base.repo CentOS-6.7-Base.repo

 

[root@localhost yum.repos.d]# cat CentOS-6.7-Base.repo

# CentOS-Base.repo

#

# The mirror system uses the connecting IP address of the client and the

# update status of each mirror to pick mirrors that are updated to and

# geographically close to the client. You should use this for CentOS updates

# unless you are manually picking other mirrors.

#

# If the mirrorlist= does not work for you, as a fall back you can try the

# remarked out baseurl= line instead.

#

#

 

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra

baseurl=http://vault.centos.org/6.7/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#released updates

[updates]

name=CentOS-$releasever - Updates

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra

baseurl=http://vault.centos.org/6.7/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra

baseurl=http://vault.centos.org/6.7/extras/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra

#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

#contrib - packages by Centos Users

[contrib]

name=CentOS-$releasever - Contrib

mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra

#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

[root@localhost yum.repos.d]#

 

[root@localhost yum.repos.d]# yum install epel-release

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package epel-release.noarch 0:6-8 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

====================================================================================================================

 Package                         Arch                      Version                  Repository                 Size

====================================================================================================================

Installing:

 epel-release                    noarch                    6-8                      extras                     14 k

 

Transaction Summary

====================================================================================================================

Install       1 Package(s)

 

Total download size: 14 k

Installed size: 22 k

Is this ok [y/N]: y

Downloading Packages:

epel-release-6-8.noarch.rpm                                                                 |  14 kB     00:00    

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de:NOKEY

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Importing GPG key 0xC105B9DE:

 Userid : CentOS-6 Key (CentOS 6Official Signing Key) <centos-6-key@centos.org>

 Package:centos-release-6-7.el6.centos.12.3.x86_64 (@anaconda-CentOS-201508042137.x86_64/6.7)

 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing :epel-release-6-8.noarch                                                                          1/1

  Verifying  : epel-release-6-8.noarch                                                                         1/1

 

Installed:

  epel-release.noarch 0:6-8                                                                                        

 

Complete!

[root@localhost yum.repos.d]#

 

4.2 更新系统

 

[root@localhostyum.repos.d]# yum update -y

Loaded plugins:fastestmirror

Setting up UpdateProcess

Loading mirror speedsfrom cached hostfile

epel/metalink                                                                               | 4.5 kB     00:00    

 * epel: mirror.premi.st

epel                                                                                        | 4.3 kB     00:00     

epel/primary_db                                                                             | 5.9 MB     00:00    

ResolvingDependencies

--> Runningtransaction check

---> Packagebash.x86_64 0:4.1.2-33.el6 will be updated

---> Packagebash.x86_64 0:4.1.2-33.el6_7.1 will be an update

---> Packageca-certificates.noarch 0:2015.2.4-65.0.1.el6_6 will be updated

---> Packageca-certificates.noarch 0:2015.2.6-65.0.1.el6_7 will be an update

---> Packagechkconfig.x86_64 0:1.3.49.3-5.el6 will be updated

---> Packagechkconfig.x86_64 0:1.3.49.3-5.el6_7.2 will be an update

---> Packagecoreutils.x86_64 0:8.4-37.el6 will be updated

---> Packagecoreutils.x86_64 0:8.4-37.el6_7.3 will be an update

---> Packagecoreutils-libs.x86_64 0:8.4-37.el6 will be updated

---> Packagecoreutils-libs.x86_64 0:8.4-37.el6_7.3 will be an update

---> Packagecronie.x86_64 0:1.4.4-15.el6 will be updated

---> Packagecronie.x86_64 0:1.4.4-15.el6_7.1 will be an update

---> Packagecronie-anacron.x86_64 0:1.4.4-15.el6 will be updated

---> Packagecronie-anacron.x86_64 0:1.4.4-15.el6_7.1 will be an update

---> Packagedb4.x86_64 0:4.7.25-19.el6_6 will be updated

---> Packagedb4.x86_64 0:4.7.25-20.el6_7 will be an update

---> Packagedb4-utils.x86_64 0:4.7.25-19.el6_6 will be updated

---> Packagedb4-utils.x86_64 0:4.7.25-20.el6_7 will be an update

---> Packagedevice-mapper.x86_64 0:1.02.95-2.el6 will be updated

---> Packagedevice-mapper.x86_64 0:1.02.95-3.el6_7.4 will be an update

---> Packagedevice-mapper-event.x86_64 0:1.02.95-2.el6 will be updated

---> Packagedevice-mapper-event.x86_64 0:1.02.95-3.el6_7.4 will be an update

---> Packagedevice-mapper-event-libs.x86_64 0:1.02.95-2.el6 will be updated

---> Packagedevice-mapper-event-libs.x86_64 0:1.02.95-3.el6_7.4 will be an update

---> Packagedevice-mapper-libs.x86_64 0:1.02.95-2.el6 will be updated

---> Packagedevice-mapper-libs.x86_64 0:1.02.95-3.el6_7.4 will be an update

---> Packagegawk.x86_64 0:3.1.7-10.el6 will be updated

---> Packagegawk.x86_64 0:3.1.7-10.el6_7.3 will be an update

---> Packageglibc.x86_64 0:2.12-1.166.el6 will be updated

---> Packageglibc.x86_64 0:2.12-1.166.el6_7.7 will be an update

---> Packageglibc-common.x86_64 0:2.12-1.166.el6 will be updated

此处省略。。。。

4.3 安装开发工具包

 

 

[root@localhostyum.repos.d]# yum groupinstall -y ‘Development Tools‘

Loaded plugins:fastestmirror

Setting up Group Process

Loading mirror speeds fromcached hostfile

 * epel: mirrors.tuna.tsinghua.edu.cn

Package1:make-3.81-20.el6.x86_64 already installed and latest version

Package 1:pkgconfig-0.23-9.1.el6.x86_64already installed and latest version

Packagebinutils-2.20.51.0.2-5.43.el6.x86_64 already installed and latest version

Resolving Dependencies

--> Running transactioncheck

---> Packageautoconf.noarch 0:2.63-5.1.el6 will be installed

--> ProcessingDependency: perl >= 5.005_03 for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl >= 5.005 for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl >= 5.000 for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(vars) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(strict) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(Text::ParseWords) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(POSIX) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(IO::File) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(Getopt::Long) for package: autoconf-2.63-5.1.el6.noarch

--> ProcessingDependency: perl(File::stat) for package: autoconf-2.63-5.1.el6.noarch

此处省略。。。。

[root@localhostyum.repos.d]# yum install curl-devel xinetd readline-devel bzip2-devel cmakediffutils gcc-g77 gd gd-devel git-core glib2-devel gmp-devel libc-client-devellibcurl-devel openssl-devel pspell-devel zlib-devel

Loaded plugins:fastestmirror

Setting up Install Process

Loading mirror speeds fromcached hostfile

 * epel: mirror.premi.st

Packagediffutils-2.8.1-28.el6.x86_64 already installed and latest version

No package gcc-g77available.

Packagegd-2.0.35-11.el6.x86_64 already installed and latest version

Packagegit-1.7.1-4.el6_7.1.x86_64 already installed and latest version

No package pspell-develavailable.

Resolving Dependencies

--> Running transactioncheck

---> Packagebzip2-devel.x86_64 0:1.0.5-7.el6_0 will be installed

---> Package cmake.x86_640:2.8.12.2-4.el6 will be installed

--> ProcessingDependency: libarchive.so.2()(64bit) for package: cmake-2.8.12.2-4.el6.x86_64

---> Packagegd-devel.x86_64 0:2.0.35-11.el6 will be installed

--> ProcessingDependency: libpng-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> ProcessingDependency: libjpeg-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> ProcessingDependency: libXpm-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> ProcessingDependency: libX11-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> ProcessingDependency: freetype-devel for package: gd-devel-2.0.35-11.el6.x86_64

--> ProcessingDependency: fontconfig-devel for package: gd-devel-2.0.35-11.el6.x86_64

---> Packageglib2-devel.x86_64 0:2.28.8-4.el6 will be installed

---> Packagegmp-devel.x86_64 0:4.3.1-7.el6_2.2 will be installed

---> Packagelibc-client-devel.x86_64 0:2007e-11.el6 will be installed

--> ProcessingDependency: libc-client = 2007e-11.el6 for package:libc-client-devel-2007e-11.el6.x86_64

--> ProcessingDependency: libc-client.so.2007()(64bit) for package: libc-client-devel-2007e-11.el6.x86_64

---> Packagelibcurl-devel.x86_64 0:7.19.7-46.el6 will be installed

--> ProcessingDependency: libidn-devel for package: libcurl-devel-7.19.7-46.el6.x86_64

---> Packageopenssl-devel.x86_64 0:1.0.1e-42.el6_7.4 will be installed

--> ProcessingDependency: krb5-devel for package: openssl-devel-1.0.1e-42.el6_7.4.x86_64

---> Packagereadline-devel.x86_64 0:6.0-4.el6 will be installed

此处省略。。。。


4.4 安装管理工具包

 

 

[root@localhostyum.repos.d]# yum groupinstall ‘System administration tools‘ --setopt=group_package_types=mandatory,default,optional

Loaded plugins:fastestmirror

Setting up Group Process

Loading mirror speeds fromcached hostfile

 * epel: mirror.premi.st

Resolving Dependencies

--> Running transactioncheck

---> Package ansible.noarch0:2.3.0.0-3.el6 will be installed

--> ProcessingDependency: sshpass for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-six for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-simplejson for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-setuptools for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-paramiko for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-keyczar for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-jinja2-26 for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-httplib2 for package: ansible-2.3.0.0-3.el6.noarch

--> ProcessingDependency: python-crypto2.6 for package: ansible-2.3.0.0-3.el6.noarch

此处省略。。。。


[root@localhostyum.repos.d]#  yum installlibselinux-python telnet wget rsync openssh-clients system-config-network-tuibind-utils vim-enhanced ntpdate cronie yum-utils strace lsof sysstat expect ncmlocate iptraf iotop dstat htop bash-completion.noarch

Loaded plugins:fastestmirror

Setting up Install Process

Loading mirror speeds fromcached hostfile

 * epel: mirror.premi.st

Packagersync-3.0.6-12.el6.x86_64 already installed and latest version

Packageopenssh-clients-5.3p1-114.el6_7.x86_64 already installed and latest version

Packagecronie-1.4.4-15.el6_7.1.x86_64 already installed and latest version

Packageexpect-5.44.1.15-5.el6_4.x86_64 already installed and latest version

Resolving Dependencies

--> Running transactioncheck

---> Packagebash-completion.noarch 1:1.3-7.el6 will be installed

---> Packagebind-utils.x86_64 32:9.8.2-0.37.rc1.el6_7.7 will be installed

--> ProcessingDependency: bind-libs = 32:9.8.2-0.37.rc1.el6_7.7 for package:32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> ProcessingDependency: liblwres.so.80()(64bit) for package:32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> ProcessingDependency: libisccfg.so.82()(64bit) for package: 32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> ProcessingDependency: libisccc.so.80()(64bit) for package:32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> ProcessingDependency: libisc.so.83()(64bit) for package:32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> Processing Dependency:libdns.so.81()(64bit) for package: 32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

--> ProcessingDependency: libbind9.so.80()(64bit) for package:32:bind-utils-9.8.2-0.37.rc1.el6_7.7.x86_64

---> Package dstat.noarch0:0.7.0-2.el6 will be installed

---> Package htop.x86_640:1.0.3-1.el6 will be installed

---> Package iotop.noarch0:0.3.2-7.el6 will be installed

---> Packageiptraf.x86_64 0:3.0.1-14.el6 will be installed

---> Packagelibselinux-python.x86_64 0:2.0.94-5.8.el6 will be installed

4.5 配置sshd

 

[root@localhost~]# vim /etc/ssh/sshd_config

PermitRootLogin yes
UseDNS no


[root@localhost~]# systemctl restart sshd


4.6 配置Selinux、防火墙

[root@localhostyum.repos.d]# chkconfig iptables off

[root@localhostyum.repos.d]# chkconfig ip6tables off

[root@localhostyum.repos.d]# chkconfig --list |grep ip

ip6tables      0:off  1:off  2:off  3:off  4:off  5:off  6:off

iptables       0:off  1:off  2:off  3:off  4:off  5:off  6:off

4.7 安装电源管理服务

 

 

[root@localhost yum.repos.d]# yum install acpid

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

 * epel:mirror.premi.st

Resolving Dependencies

--> Running transaction check

---> Package acpid.x86_64 0:1.0.10-2.1.el6 willbe installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

====================================================================================================================

 Package                  Arch                      Version                           Repository               Size

====================================================================================================================

Installing:

 acpid                    x86_64                    1.0.10-2.1.el6                    base                     36 k

 

Transaction Summary

====================================================================================================================

Install      1 Package(s)

 

Total download size: 36 k

Installed size: 73 k

Is this ok [y/N]: y

Downloading Packages:

acpid-1.0.10-2.1.el6.x86_64.rpm                                                              |  36 kB    00:00    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing: acpid-1.0.10-2.1.el6.x86_64                                                                      1/1

 Verifying  :acpid-1.0.10-2.1.el6.x86_64                                                                     1/1

 

Installed:

 acpid.x86_64 0:1.0.10-2.1.el6                                                                                    

 

Complete!

[root@localhost yum.repos.d]# chkconfig acpid on

 

 

 

4.8 配置启动日志显示

 

 

[root@localhostyum.repos.d]# cat /boot/grub/grub.conf

# grub.confgenerated by anaconda

#

# Note thatyou do not have to rerun grub after making changes to this file

# NOTICE:  You do not have a /boot partition.  This means that

#          all kernel and initrd paths arerelative to /, eg.

#          root (hd0,0)

#          kernel /boot/vmlinuz-version roroot=/dev/vda1

#          initrd /boot/initrd-[generic-]version.img

#boot=/dev/vda

default=0

timeout=3

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

hiddenmenu

title CentOS(2.6.32-573.26.1.el6.x86_64)

    root (hd0,0)

    kernel/boot/vmlinuz-2.6.32-573.26.1.el6.x86_64 roroot=UUID=6ebce6cc-aa6e-486d-9c28-0d631a02a992 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DMconsole=tty0 console=ttyS0,115200n8 ipv6.disable=1

    initrd/boot/initramfs-2.6.32-573.26.1.el6.x86_64.img

title CentOS 6(2.6.32-573.el6.x86_64)

    root (hd0,0)

    kernel /boot/vmlinuz-2.6.32-573.el6.x86_64ro root=UUID=6ebce6cc-aa6e-486d-9c28-0d631a02a992 rd_NO_LUKS rd_NO_LVMLANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DMconsole=tty0 console=ttyS0,115200n8 ipv6.disable=1

    initrd/boot/initramfs-2.6.32-573.el6.x86_64.img

 

 

 

4.9 安装配置qemu-guest-agent

 

[root@localhostyum.repos.d]# yum install qemu-guest-agent

Loadedplugins: fastestmirror

Setting upInstall Process

Loading mirrorspeeds from cached hostfile

 * epel: mirror.premi.st

ResolvingDependencies

--> Runningtransaction check

--->Package qemu-guest-agent.x86_64 2:0.12.1.2-2.479.el6_7.4 will be installed

-->Finished Dependency Resolution

 

DependenciesResolved

 

====================================================================================================================

 Package                       Arch                Version                               Repository            Size

====================================================================================================================

Installing:

 qemu-guest-agent              x86_64              2:0.12.1.2-2.479.el6_7.4              updates              493 k

 

TransactionSummary

====================================================================================================================

Install       1 Package(s)

 

Total downloadsize: 493 k

Installedsize: 229 k

Is this ok[y/N]: y

DownloadingPackages:

qemu-guest-agent-0.12.1.2-2.479.el6_7.4.x86_64.rpm                                           |493 kB     00:00    

Runningrpm_check_debug

RunningTransaction Test

TransactionTest Succeeded

RunningTransaction

  Installing :2:qemu-guest-agent-0.12.1.2-2.479.el6_7.4.x86_64                                                 1/1

  Verifying : 2:qemu-guest-agent-0.12.1.2-2.479.el6_7.4.x86_64                                                1/1

 

Installed:

  qemu-guest-agent.x86_642:0.12.1.2-2.479.el6_7.4                                                                  

 

Complete!

[root@localhostyum.repos.d]#

 

[root@localhostyum.repos.d]# cat /etc/sysconfig/qemu-ga

# Transportmethod may be one of following:

#   * unix-listen

#   * virtio-serial

#   * isa-serial

# Default:virtio-serial

TRANSPORT_METHOD="virtio-serial"

 

# You also canoverride the device/socket path

# Default:/dev/virtio-ports/org.qemu.guest_agent.0

DEVPATH="/dev/virtio-ports/org.qemu.guest_agent.0"

 

# If logfileis unset it defaults to stderr but the daemon

# function ofinit script redirects stderr to /dev/null

LOGFILE="/var/log/qemu-ga/qemu-ga.log"

 

# Overridepidfile name

# Default:/var/run/qemu-ga.pid

PIDFILE="/var/run/qemu-ga.pid"

 

# SELinuxnote:

#  About guest arbitrary file read/write

#

# A newselinux policy is introduced on RHEL-6.4 to deny qemu-ga to

# read/writearbitrary guest files except the device file used to talk

# with hostprocesses, LOGFILE and PIDFILE.

#

# You candisable this policy by "restorecon -R -v /usr/bin/qemu-ga"

 

#Comma-separated blacklist of RPCs to disable or empty list to enable all

# Tip: You canget the list of RPC commands using `qemu-ga --blacklist ?`

# Default:blank list to enable all RPCs

# Note: Thereshould be no spaces between commas and commands in the blacklist

#BLACKLIST_RPC="guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush"

BLACKLIST_RPC=""

 

# Enablefsfreeze hook. See the --fsfreeze-hook option in "qemu-ga --help".

FSFREEZE_HOOK_ENABLE=0

 

# Set theoption argument for --fsfreeze-hook, which is the full pathname of

# the hookscript. An empty or unset value designates the default script

# (invoke"qemu-ga --help" to interrogate).

#

# This setting(independently of value) takes effect only when

#FSFREEZE_HOOK_ENABLE is nonzero.

#FSFREEZE_HOOK_PATHNAME=/usr/libexec/qemu-ga/fsfreeze-hook

 

 

 

4.10 配置zeroconf route

 

[root@localhost ~]# echo"NOZEROCONF=yes" >> /etc/sysconfig/network

[root@localhost ~]# cat /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=localhost.localdomain

NOZEROCONF=yes

4.11 安装配置cloud 软件包

 

 

[root@localhostyum.repos.d]# yum install python-prettytable

Loadedplugins: fastestmirror

Setting upInstall Process

Loading mirrorspeeds from cached hostfile

 * epel: mirror.premi.st

ResolvingDependencies

--> Runningtransaction check

--->Package python-prettytable.noarch 0:0.7.2-1.el6.centos will be installed

-->Finished Dependency Resolution

 

DependenciesResolved

 

====================================================================================================================

 Package                          Arch                 Version                           Repository            Size

====================================================================================================================

Installing:

 python-prettytable               noarch               0.7.2-1.el6.centos                extras                37 k

 

TransactionSummary

====================================================================================================================

Install       1 Package(s)

 

Total downloadsize: 37 k

Installedsize: 181 k

Is this ok[y/N]: y

DownloadingPackages:

python-prettytable-0.7.2-1.el6.centos.noarch.rpm                                            |  37 kB     00:00    

Runningrpm_check_debug

RunningTransaction Test

TransactionTest Succeeded

RunningTransaction

  Installing :python-prettytable-0.7.2-1.el6.centos.noarch                                                    1/1

  Verifying : python-prettytable-0.7.2-1.el6.centos.noarch                                                    1/1

 

Installed:

  python-prettytable.noarch0:0.7.2-1.el6.centos                                                                   

 

Complete!

[root@localhostyum.repos.d]# yum install cloud-init --disablerepo=extras

Loadedplugins: fastestmirror

Setting upInstall Process

Loading mirrorspeeds from cached hostfile

 * epel: mirrors.tuna.tsinghua.edu.cn

ResolvingDependencies

--> Runningtransaction check

--->Package cloud-init.noarch 0:0.7.4-2.el6 will be installed

-->Processing Dependency: python-boto >= 2.6.0 for package: cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: python-requests for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: python-jsonpatch for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: python-configobj for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: python-cheetah for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: python-argparse for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: policycoreutils-python for package:cloud-init-0.7.4-2.el6.noarch

-->Processing Dependency: dmidecode for package: cloud-init-0.7.4-2.el6.noarch

--> Runningtransaction check

--->Package dmidecode.x86_64 1:2.12-6.el6 will be installed

--->Package policycoreutils-python.x86_64 0:2.0.83-24.el6 will be installed

-->Processing Dependency: libsemanage-python >= 2.0.43-4 for package:policycoreutils-python-2.0.83-24.el6.x86_64

-->Processing Dependency: audit-libs-python >= 1.4.2-1 for package:policycoreutils-python-2.0.83-24.el6.x86_64

-->Processing Dependency: setools-libs-python for package:policycoreutils-python-2.0.83-24.el6.x86_64

-->Processing Dependency: libcgroup for package:policycoreutils-python-2.0.83-24.el6.x86_64

--->Package python-argparse.noarch 0:1.2.1-2.1.el6 will be installed

--->Package python-cheetah.x86_64 0:2.4.1-1.el6 will be installed

-->Processing Dependency: python-pygments for package:python-cheetah-2.4.1-1.el6.x86_64

-->Processing Dependency: python-markdown for package: python-cheetah-2.4.1-1.el6.x86_64

--->Package python-configobj.noarch 0:4.6.0-3.el6 will be installed

--->Package python-jsonpatch.noarch 0:1.2-2.el6 will be installed

-->Processing Dependency: python-jsonpointer for package:python-jsonpatch-1.2-2.el6.noarch

--->Package python-requests.noarch 0:2.6.0-3.el6 will be installed

此处省略。。。。

5. 封装镜像

 

[root@localhostcloud]# shutdown -h now

 

Broadcastmessage from root@localhost.localdomain

    (/dev/pts/0) at 17:16 ...

 

The system isgoing down for halt NOW!

[root@localhostcloud]# Connection to 192.168.122.53 closed by remote host.

Connection to192.168.122.53 closed.

 

root@UKVM-IMG:~#virt-sysprep -d centos-6.7

[   0.0] Examining the guest ...

[   7.3] Performing "abrt-data" ...

[   7.3] Performing "bash-history" ...

[   7.4] Performing "blkid-tab" ...

[   7.4] Performing "crash-data" ...

[   7.4] Performing "cron-spool" ...

[   7.4] Performing"dhcp-client-state" ...

[   7.4] Performing"dhcp-server-state" ...

[   7.4] Performing "dovecot-data" ...

[   7.4] Performing "logfiles" ...

[   7.5] Performing "machine-id" ...

[   7.5] Performing "mail-spool" ...

[   7.5] Performing "net-hostname" ...

[   7.6] Performing "net-hwaddr" ...

[   7.6] Performing "pacct-log" ...

[   7.6] Performing"package-manager-cache" ...

[   7.6] Performing "pam-data" ...

[   7.6] Performing "puppet-data-log"...

[   7.6] Performing"rh-subscription-manager" ...

[   7.6] Performing "rhn-systemid" ...

[   7.6] Performing "rpm-db" ...

[   7.6] Performing "samba-db-log" ...

[   7.6] Performing "script" ...

[   7.6] Performing "smolt-uuid" ...

[   7.6] Performing "ssh-hostkeys" ...

[   7.7] Performing "ssh-userdir" ...

[   7.7] Performing "sssd-db-log" ...

[   7.7] Performing "tmp-files" ...

[   7.7] Performing"udev-persistent-net" ...

[   7.7] Performing "utmp" ...

[   7.7] Performing "yum-uuid" ...

[   7.7] Performing "customize" ...

[   7.7] Setting a random seed

[   7.7] Performing "lvm-uuids" ...

 

 

6. 上传镜像

 

 

root@node-27:~# qemu-img convert -f qcow2 -O rawcentos-6.7-L.qcow2 centos-6.7-L.raw  

root@node-27:~# source openrc3

root@node-27:~#

You have new mail in /var/mail/root

root@node-27:~#

root@node-27:~# openstack image create"centos-6.7-L" \

> --file centos-6.7-L.raw \

> --disk-format raw --container-format bare \

> --public

+------------------+--------------------------------------+

| Field           | Value                               |

+------------------+--------------------------------------+

| checksum        | 3c458b30b08a2ad7d87e09ebe26e969e    |

| container_format | bare                                 |

| created_at      | 2017-06-17T04:55:29.000000          |

| deleted         | False                               |

| deleted_at      | None                                |

| disk_format     | raw                                 |

| id              | 4bf47823-bd0a-4348-8636-7abb2b9e6757 |

| is_public       | True                                |

| min_disk        | 0                                    |

| min_ram         | 0                                   |

| name            | centos-6.7-L                    |

| owner           | 74f3bf2affa8443bbcd77b51173bf0de    |

| properties      |                                     |

| protected       | False                               |

| size            | 21474836480                         |

| status          | active                              |

| updated_at      | 2017-06-17T04:56:40.000000           |

| virtual_size    | None                                |

+------------------+--------------------------------------+

root@node-27:~#

 

7.创建实例测试

 

创建实例

技术分享

完成。

本文出自 “清风明月” 博客,请务必保留此出处http://coolsky.blog.51cto.com/177347/1939684

OpenStack制作CentOS6.7镜像