完成安装配置工作,最后点击右下角的reboot重启退出虚拟机.
4. 配置OS
安装好系统后,还需要进行配置才能作为glance镜像使用,启动虚拟机:
root@UKVM-IMG:/var/lib/libvirt/images# virsh list --all
Id Name State
----------------------------------------------------
- centos7.2.1511-L shut off
- centos72-L shut off
root@UKVM-IMG:/var/lib/libvirt/images# 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 <<EOF
> # 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
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
[root@localhost~]# systemctl restart sshd
4.6 配置Selinux、防火墙
[root@localhost~]# vim /etc/sysconfig/selinux
[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)
==============================================================================================================
Package Arch Version Repository Size
==============================================================================================================
Installing:
acpid x86_64 2.0.19-6.el7 base 68 k
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
[root@localhost~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grubconfiguration file ...
Found linuximage: /boot/vmlinuz-3.10.0-327.36.3.el7.x86_64
Found initrdimage: /boot/initramfs-3.10.0-327.36.3.el7.x86_64.img
Found linuximage: /boot/vmlinuz-3.10.0-327.el7.x86_64
Found initrdimage: /boot/initramfs-3.10.0-327.el7.x86_64.img
Found linuximage: /boot/vmlinuz-0-rescue-5c4a4477298d9246974f324ee429b45d
Found initrdimage: /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
[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.
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/images#
root@UKVM-IMG:/var/lib/libvirt/images#
root@UKVM-IMG:/var/lib/libvirt/images#virsh list --all
Id Name State
----------------------------------------------------
7 centos72-L running
- centos7.2.1511-L shut off