1.下载镜像

直接访问官方镜像地址下载,注意选择中国的镜像源,相对国外镜像下载速率比较快,进入后选择版本为7.2.1511,在isos目录下下载x86_64的Minimal镜像.
2.创建虚拟机

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

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths# qemu-img create -f qcow2centos7.2.1511-L.qcow2 20G

Formatting 'centos7.2.1511-L.qcow2', fmt=qcow2 size=21474836480encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

快速创建并启动虚拟机:

NAME=centos7.2.1511-L

ROOT_DISK=centos7.2.1511-L.qcow2

CDROM=/CentOS-7-x86_64-Minimal-1511.iso

sudo virt-install --virt-type kvm --name $NAME --ram 1024 \

  --disk $ROOT_DISK,format=qcow2 \

  --network network=default \

  --graphics vnc,listen=0.0.0.0--noautoconsole \

  --os-type=linux --os-variant=rhel7\

  --cdrom=$CDROM

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

进入虚拟机控制台可以看到Centos的启动菜单,选择Install Centos 7,继续选择语言后将进入INSTALLIONSUMMARY,其中大多数配置默认即可,SOFTWARE SELECTION选择Minimal Install,INSTALLATION DESTINATION需要选择手动配置分区,只需要一个根分区即可,不需要swap分区,文件系统选择ext4,存储驱动选择Virtio Block Device,设置网络和初始Root密码,如图:

OpenStack制作CentOS7.2.1511镜像_第1张图片

OpenStack制作CentOS7.2.1511镜像_第2张图片

OpenStack制作CentOS7.2.1511镜像_第3张图片

OpenStack制作CentOS7.2.1511镜像_第4张图片

OpenStack制作CentOS7.2.1511镜像_第5张图片

OpenStack制作CentOS7.2.1511镜像_第6张图片

OpenStack制作CentOS7.2.1511镜像_第7张图片

完成安装配置工作,最后点击右下角的reboot重启退出虚拟机.
4. 配置OS
安装好系统后,还需要进行配置才能作为glance镜像使用,启动虚拟机:
root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths# virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     centos7.2.1511-L               shut off
 -     centos72-L                     shut off

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths# virsh start centos7.2.1511-L
Domain centos7.2.1511-L started
4.1 配置yum仓库

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv * bak/
mv: cannot move ‘bak’ to a subdirectory of itself, ‘bak/bak’
[root@localhost yum.repos.d]# ls
bak
[root@localhost yum.repos.d]# cat >> CentOS7-2-1511-Base.repo <> # CentOS7.2.1511-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/7.2.1511/os/$basearch/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #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/7.2.1511/updates/$basearch/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #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/7.2.1511/extras/$basearch/
> gpgcheck=1
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
>
> #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://vault.centos.org/7.2.1511/centosplus/$basearch/
> gpgcheck=1
> enabled=0
> gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
> EOF
yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================================================================================
 Package                                                       Arch                                                    Version                                                Repository                                               Size
============================================================================================================================================================================================================================================
Installing:
 epel-release                                                  noarch                                                  7-6                                                    extras                                                   14 k

Transaction Summary
============================================================================================================================================================================================================================================
Install  1 Package

Total download size: 14 k
Installed size: 24 k
Is this ok [y/d/N]: y  
Downloading packages:
epel-release-7-6.noarch.rpm                                                                                                                                                                                          |  14 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-6.noarch                                                                                                                                                                                                  1/1
  Verifying  : epel-release-7-6.noarch                                                                                                                                                                                                  1/1

Installed:
  epel-release.noarch 0:7-6                                                                                                                                                                                                                 

Complete!
4.2 更新系统

[root@localhost yum.repos.d]# yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package NetworkManager.x86_64 1:1.0.6-27.el7 will be updated
---> Package NetworkManager.x86_64 1:1.0.6-31.el7_2 will be an update
---> Package NetworkManager-libnm.x86_64 1:1.0.6-27.el7 will be updated
---> Package NetworkManager-libnm.x86_64 1:1.0.6-31.el7_2 will be an update
---> Package NetworkManager-tui.x86_64 1:1.0.6-27.el7 will be updated
---> Package NetworkManager-tui.x86_64 1:1.0.6-31.el7_2 will be an update
---> Package NetworkManager-wifi.x86_64 1:1.0.6-27.el7 will be updated
---> Package NetworkManager-wifi.x86_64 1:1.0.6-31.el7_2 will be an update
---> Package avahi-autoipd.x86_64 0:0.6.31-15.el7 will be updated
---> Package avahi-autoipd.x86_64 0:0.6.31-15.el7_2.1 will be an update
---> Package avahi-libs.x86_64 0:0.6.31-15.el7 will be updated
---> Package avahi-libs.x86_64 0:0.6.31-15.el7_2.1 will be an update
---> Package bash.x86_64 0:4.2.46-19.el7 will be updated

省略。。。

4.3 安装开发工具包

[root@localhost ~]# yum groupinstall -y 'Development Tools'
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
base                                                                                                                                                                                                                 | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                               | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                              | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.69-11.el7 will be installed
--> Processing Dependency: perl >= 5.006 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: m4 >= 1.4.14 for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(warnings) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(vars) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(strict) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(constant) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(POSIX) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(IO::File) for package: autoconf-2.69-11.el7.noarch
--> Processing Dependency: perl(Getopt::Long) for package: autoconf-2.69-11.el7.noarch

省略。。。

4.4 安装管理工具包

[root@localhost ~]# yum groupinstall system-admin-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Warning: Group system-admin-tools does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost ~]# yum groupinfo 'System Administration Tools'
Loaded plugins: fastestmirror
base                                                                                                                                                                                                                 | 3.6 kB  00:00:00     
extras                                                                                                                                                                                                               | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                              | 3.4 kB  00:00:00     
(1/4): extras/x86_64/primary_db                                                                                                                                                                                      | 166 kB  00:00:02     
(2/4): base/x86_64/group_gz                                                                                                                                                                                          | 155 kB  00:00:03     
(3/4): base/x86_64/primary_db                                                                                                                                                                                        | 5.3 MB  00:00:11     
(4/4): updates/x86_64/primary_db                                                                                                                                                                                     | 9.1 MB  00:00:12     
Determining fastest mirrors

Group: System Administration Tools
 Group-Id: system-admin-tools
 Description: Utilities useful in system administration.
 Optional Packages:
   conman
   crypto-utils
   dump
   expect
   hardlink
   lsscsi
   mc
   mgetty
   pexpect
   rdist
   rear
   rrdtool
   screen
   scrub
   snapper
   symlinks
   system-storage-manager
   tree
   xdelta
[root@localhost ~]# yum groupinstall 'System Administration Tools'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Warning: Group system-admin-tools does not have any packages to install.
Maybe run: yum groups mark install (see man yum)
No packages in any requested group available to install or update
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors


[root@localhost ~]# yum groupinstall "System Admini*" --setopt=group_package_types=mandatory,default,optional
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package conman.x86_64 0:0.2.7-12.el7 will be installed
--> Processing Dependency: libipmiconsole.so.2()(64bit) for package: conman-0.2.7-12.el7.x86_64
---> Package crypto-utils.x86_64 0:2.4.1-42.el7 will be installed
--> Processing Dependency: perl(Newt) for package: crypto-utils-2.4.1-42.el7.x86_64
---> Package dump.x86_64 1:0.4-0.22.b44.el7 will be installed
--> Processing Dependency: rmt for package: 1:dump-0.4-0.22.b44.el7.x86_64
---> Package expect.x86_64 0:5.45-14.el7_1 will be installed
--> Processing Dependency: libtcl8.5.so()(64bit) for package: expect-5.45-14.el7_1.x86_64

省略。。。

4.5 配置sshd

 

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

wKioL1k3r4DD9TxRAAAI0_FhhuQ247.png-wh_50

wKiom1k3r4Cx6-uFAAAF2HDmFR0612.png-wh_50

[root@localhost~]# systemctl restart sshd

 

4.6 配置Selinux、防火墙

[root@localhost~]# vim /etc/sysconfig/selinux

wKiom1k3r97A_XuNAAAFrIi5xe4408.png-wh_50

 [root@localhost~]# systemctl list-unit-files |grep firewall

[root@localhost~]# systemctl status firewall

firewall.service

   Loaded: not-found (Reason: No such file ordirectory)

   Active: inactive (dead)


4.7 安装电源管理服务

[root@localhost ~]# yum install acpid
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * epel: mirror.premi.st
Resolving Dependencies
--> Running transaction check
---> Package acpid.x86_64 0:2.0.19-6.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================
 Package                 Arch                     Version                        Repository              Size
==============================================================================================================
Installing:
 acpid                   x86_64                   2.0.19-6.el7                   base                    68 k

Transaction Summary
==============================================================================================================
Install  1 Package

Total download size: 68 k
Installed size: 145 k
Is this ok [y/d/N]: y
Downloading packages:
acpid-2.0.19-6.el7.x86_64.rpm                                                          |  68 kB  00:00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : acpid-2.0.19-6.el7.x86_64                                                                  1/1
  Verifying  : acpid-2.0.19-6.el7.x86_64                                                                  1/1

Installed:
  acpid.x86_64 0:2.0.19-6.el7                                                                                 

Complete!
[root@localhost ~]# systemctl start acpid.service
[root@localhost ~]# systemctl enable acpid.service
[root@localhost ~]# systemctl status acpid.service
● acpid.service - ACPI Event Daemon
   Loaded: loaded (/usr/lib/systemd/system/acpid.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-06-07 11:13:15 CST; 25s ago
 Main PID: 1079 (acpid)
   CGroup: /system.slice/acpid.service
           └─1079 /usr/sbin/acpid

Jun 07 11:13:15 localhost.localdomain systemd[1]: Starting ACPI Event Daemon...
Jun 07 11:13:15 localhost.localdomain systemd[1]: Started ACPI Event Daemon.
Jun 07 11:13:15 localhost.localdomain acpid[1079]: starting up with netlink and the input layer
Jun 07 11:13:15 localhost.localdomain acpid[1079]: skipping incomplete file /etc/acpi/events/videoconf
Jun 07 11:13:15 localhost.localdomain acpid[1079]: 1 rule loaded
Jun 07 11:13:15 localhost.localdomain acpid[1079]: waiting for events: event logging is off
[root@localhost ~]#


4.8 配置启动日志显示

[root@localhost~]# vim /etc/default/grub

wKiom1k3sGqgthb8AAANQMlh9BU920.png-wh_50

 [root@localhost~]# grub2-mkconfig -o /boot/grub2/grub.cfg

Generating grubconfiguration file ...

Found linuxp_w_picpath: /boot/vmlinuz-3.10.0-327.36.3.el7.x86_64

Found initrdp_w_picpath: /boot/initramfs-3.10.0-327.36.3.el7.x86_64.img

Found linuxp_w_picpath: /boot/vmlinuz-3.10.0-327.el7.x86_64

Found initrdp_w_picpath: /boot/initramfs-3.10.0-327.el7.x86_64.img

Found linuxp_w_picpath: /boot/vmlinuz-0-rescue-5c4a4477298d9246974f324ee429b45d

Found initrdp_w_picpath: /boot/initramfs-0-rescue-5c4a4477298d9246974f324ee429b45d.img

done


4.9 安装配置qemu-guest-agent

 

[root@localhost~]# yum install -y qemu-guest-agent

Loadedplugins: fastestmirror

Loading mirrorspeeds from cached hostfile

 * epel: mirror.premi.st

ResolvingDependencies

--> Runningtransaction check

--->Package qemu-guest-agent.x86_64 10:2.3.0-4.el7 will be installed

-->Finished Dependency Resolution

 

DependenciesResolved

 

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

 Package                        Arch                 Version                         Repository          Size

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

Installing:

 qemu-guest-agent               x86_64               10:2.3.0-4.el7                  base               121 k

 

TransactionSummary

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

Install  1 Package

 

Total downloadsize: 121 k

Installedsize: 398 k

Downloadingpackages:

qemu-guest-agent-2.3.0-4.el7.x86_64.rpm                                               | 121 kB  00:00:09    

Runningtransaction check

Runningtransaction test

Transactiontest succeeded

Runningtransaction

  Installing : 10:qemu-guest-agent-2.3.0-4.el7.x86_64                                                    1/1

  Verifying : 10:qemu-guest-agent-2.3.0-4.el7.x86_64                                                    1/1

 

Installed:

  qemu-guest-agent.x86_64 10:2.3.0-4.el7                                                                      

 Complete!

 

[root@localhost~]# vim /etc/sysconfig/qemu-ga

OpenStack制作CentOS7.2.1511镜像_第8张图片

4.10 配置zeroconf route

 

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

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

# Created byanaconda

NOZEROCONF=yes

4.11 安装配置cloud 软件包

 

[root@localhost~]# yum install cloud-init cloud-utils cloud-utils-growpart

Loadedplugins: fastestmirror

Loading mirrorspeeds from cached hostfile

 * epel: mirror.premi.st

ResolvingDependencies

--> Runningtransaction check

--->Package cloud-init.x86_64 0:0.7.5-10.el7.centos.1 will be installed

-->Processing Dependency: python-requests for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: python-prettytable for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: python-jsonpatch for package: cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: python-cheetah for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: python-boto for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: policycoreutils-python for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: net-tools for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

-->Processing Dependency: PyYAML for package:cloud-init-0.7.5-10.el7.centos.1.x86_64

--->Package cloud-utils.x86_64 0:0.27-20.el7.centos will be installed

-->Processing Dependency: qemu-img for package:cloud-utils-0.27-20.el7.centos.x86_64

-->Processing Dependency: python-paramiko for package:cloud-utils-0.27-20.el7.centos.x86_64

-->Processing Dependency: euca2ools for package:cloud-utils-0.27-20.el7.centos.x86_64

--->Package cloud-utils-growpart.x86_64 0:0.27-20.el7.centos will be installed

--> Runningtransaction check

--->Package PyYAML.x86_64 0:3.10-11.el7 will be installed

-->Processing Dependency: libyaml-0.so.2()(64bit) for package:PyYAML-3.10-11.el7.x86_64

--->Package euca2ools.noarch 0:3.4.1-1.el7 will be installed

-->Processing Dependency: python-six >= 1.8 for package:euca2ools-3.4.1-1.el7.noarch

-->Processing Dependency: python-requestbuilder >= 0.6 for package:euca2ools-3.4.1-1.el7.noarch

-->Processing Dependency: python-progressbar for package:euca2ools-3.4.1-1.el7.noarch

-->Processing Dependency: python-lxml for package: euca2ools-3.4.1-1.el7.noarch

-->Processing Dependency: gdisk for package: euca2ools-3.4.1-1.el7.noarch

--->Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed

--->Package policycoreutils-python.x86_64 0:2.2.5-20.el7 will be installed

-->Processing Dependency: libsemanage-python >= 2.1.10-1 for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: audit-libs-python >= 2.1.3-4 for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: python-IPy for package:policycoreutils-python-2.2.5-20.el7.x86_64

--> ProcessingDependency: libqpol.so.1(VERS_1.4)(64bit) for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: libcgroup for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: checkpolicy for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: libqpol.so.1()(64bit) for package:policycoreutils-python-2.2.5-20.el7.x86_64

-->Processing Dependency: libapol.so.4()(64bit) for package:policycoreutils-python-2.2.5-20.el7.x86_64

--->Package python-cheetah.x86_64 0:2.4.4-5.el7.centos will be installed

-->Processing Dependency: python-pygments for package:python-cheetah-2.4.4-5.el7.centos.x86_64

-->Processing Dependency: python-markdown for package:python-cheetah-2.4.4-5.el7.centos.x86_64

--->Package python-jsonpatch.noarch 0:1.2-3.el7.centos will be installed

-->Processing Dependency: python-jsonpointer for package:python-jsonpatch-1.2-3.el7.centos.noarch

--->Package python-prettytable.noarch 0:0.7.2-2.el7.centos will be installed

--->Package python-requests.noarch 0:2.6.0-1.el7_1 will be installed

-->Processing Dependency: python-urllib3 >= 1.10.2-1 for package:python-requests-2.6.0-1.el7_1.noarch

--->Package python2-boto.noarch 0:2.45.0-3.el7 will be installed

-->Processing Dependency: python-rsa for package: python2-boto-2.45.0-3.el7.noarch

--->Package python2-paramiko.noarch 0:1.16.1-2.el7 will be installed

-->Processing Dependency: python2-crypto >= 2.1 for package:python2-paramiko-1.16.1-2.el7.noarch

-->Processing Dependency: python2-ecdsa for package:python2-paramiko-1.16.1-2.el7.noarch

--->Package qemu-img.x86_64 10:1.5.3-105.el7_2.7 will be installed

-->Processing Dependency: libgfapi.so.0(GFAPI_3.5.0)(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libgfapi.so.0(GFAPI_3.4.0)(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libtcmalloc.so.4()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: librbd.so.1()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: librados.so.2()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libiscsi.so.2()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libgfxdr.so.0()(64bit) for package: 10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libgfrpc.so.0()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libgfapi.so.0()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

-->Processing Dependency: libaio.so.1()(64bit) for package:10:qemu-img-1.5.3-105.el7_2.7.x86_64

--> Runningtransaction check

--->Package audit-libs-python.x86_64 0:2.4.1-5.el7 will be installed

--->Package checkpolicy.x86_64 0:2.1.12-6.el7 will be installed

--->Package gdisk.x86_64 0:0.8.6-5.el7 will be installed

-->Processing Dependency: libicuuc.so.50()(64bit) for package:gdisk-0.8.6-5.el7.x86_64

-->Processing Dependency: libicuio.so.50()(64bit) for package:gdisk-0.8.6-5.el7.x86_64

--->Package glusterfs-api.x86_64 0:3.7.1-16.0.1.el7.centos will be installed

-->Processing Dependency: glusterfs-client-xlators = 3.7.1-16.0.1.el7.centos forpackage: glusterfs-api-3.7.1-16.0.1.el7.centos.x86_64

-->Processing Dependency: glusterfs = 3.7.1-16.0.1.el7.centos for package: glusterfs-api-3.7.1-16.0.1.el7.centos.x86_64

--->Package glusterfs-libs.x86_64 0:3.7.1-16.0.1.el7.centos will be installed

-->Processing Dependency: rsyslog-mmjsonparse for package:glusterfs-libs-3.7.1-16.0.1.el7.centos.x86_64

--->Package gperftools-libs.x86_64 0:2.4-7.el7 will be installed

-->Processing Dependency: libunwind.so.8()(64bit) for package:gperftools-libs-2.4-7.el7.x86_64

--->Package libaio.x86_64 0:0.3.109-13.el7 will be installed

--->Package libcgroup.x86_64 0:0.41-8.el7 will be installed

--->Package libiscsi.x86_64 0:1.9.0-6.el7 will be installed

--->Package librados2.x86_64 1:0.80.7-3.el7 will be installed

省略。。。


[root@localhost~]# useradd -u 1000 centos -s /sbin/nologin

[root@localhost~]# passwd centos

Changingpassword for user centos.

New password:

BAD PASSWORD:The password is shorter than 8 characters

Retype newpassword:

passwd: allauthentication tokens updated successfully.

 

 

 

[root@localhostcloud]# cat cloud.cfg

users:

 - default

 

disable_root:0

ssh_pwauth:   1

 

locale_configfile:/etc/sysconfig/i18n

mount_default_fields:[~, ~, 'auto', 'defaults,nofail', '0', '2']

resize_rootfs:1

resize_rootfs_tmp:/dev

ssh_deletekeys:   0

ssh_genkeytypes:  ~

syslog_fix_perms:~

 

growpart:

 mode: auto

 devices: ['/']

 

cloud_init_modules:

 - migrator

 - bootcmd

 - write-files

 - growpart

 - resizefs

 - set_hostname

 - update_hostname

 - update_etc_hosts

 - rsyslog

 - users-groups

 - ssh

 

cloud_config_modules:

 - mounts

 - locale

 - set-passwords

 - yum-add-repo

 - package-update-upgrade-install

 - timezone

 - puppet

 - chef

 - salt-minion

 - mcollective

 - disable-ec2-metadata

 - runcmd

 

cloud_final_modules:

 - rightscale_userdata

 - scripts-per-once

 - scripts-per-boot

 - scripts-per-instance

 - scripts-user

 - ssh-authkey-fingerprints

 - keys-to-console

 - phone-home

 - final-message

 

system_info:

  default_user:

    name: centos

    lock_passwd: true

    gecos: Cloud User

    groups: [wheel, adm]

    sudo: ["ALL=(ALL) NOPASSWD:ALL"]

    shell: /bin/bash

  distro: rhel

  paths:

    cloud_dir: /var/lib/cloud

    templates_dir: /etc/cloud/templates

  ssh_svcname: sshd

 

#vim:syntax=yaml

 

 

[root@localhost~]# rpm -qa kernel | sed 's/^kernel-//' | xargs -I {} dracut -f /boot/initramfs-{}.img {}

 

5. 封装镜像

[root@localhost~]# shutdown -h now

Connection to192.168.122.233 closed by remote host.

Connection to192.168.122.233 closed.

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths#

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths#

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths#virsh list --all

 Id   Name                          State

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

 7    centos72-L                    running

 -    centos7.2.1511-L              shut off

 

 

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths#virt-sysprep -d centos7.2.1511-L

[   0.0] Examining the guest ...

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

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

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

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

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

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

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

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

[   9.8] Performing "logfiles" ...

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

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

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

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

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

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

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

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

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

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

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

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

[  10.1] Performing "script" ...

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

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

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

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

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

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

[  10.2] Performing "utmp" ...

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

[  10.2] Performing "customize" ...

[  10.2] Setting a random seed

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

root@UKVM-IMG:/var/lib/libvirt/p_w_picpaths#


6. 上传镜像

 

 

root@node-27:~#qemu-img convert -f qcow2 -O raw centos7.2.1511-L.qcow2centos7.2.1511-L.raw  

root@node-27:~#source openrc3

root@node-27:~#

You have newmail in /var/mail/root

root@node-27:~#

root@node-27:~#openstack p_w_picpath create "centos7.2.1511-L" \

> --filecentos7.2.1511-L.raw \

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

> --public

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

| Field            | Value                                |

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

|checksum         |3c458b30b08a2ad7d87e09ebe26e969e     |

|container_format | bare                                 |

|created_at       | 2017-06-07T04: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             | centos7.2.1511-L                     |

| owner            |74f3bf2affa8443bbcd77b51173bf0de     |

|properties       |                                      |

|protected        | False                                |

| size             | 21474836480                          |

| status           | active                               |

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

|virtual_size     | None                                 |

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

root@node-27:~#

 

7.创建实例测试

 

创建实例


OpenStack制作CentOS7.2.1511镜像_第9张图片

完成。