2021-05-12 14:32:11
OpenStack製作CentOS6.7映象
1.下載映象
直接存取官方映象地址下載,注意選擇中國的映象源,相對國外映象下載速率比較快,進入後選擇版本為6.7,在isos目錄下下載x86_64的Minimal映象.
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]#
更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2017-06/144959p2.htm
相關文章