[原]獲取openstack-pike安裝包

linux version: CentOS 7.5.1804linux

#進入倉庫配置目錄

cd /etc/yum.repo.d/

#批量重命名全部文件

for files in `ls *`; do mv ${files} ${files}.bak; done

#更新倉庫文件指引
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#建立新的倉庫文件
vim cloud.repo [cloud] name
=CentOS-7.5.1804 - cloud - mirrors.aliyun.com failovermethod=priority baseurl=http://mirrors.aliyun.com/centos/7.5.1804/cloud/$basearch/openstack-pike/ http://mirrors.aliyuncs.com/centos/7.5.1804/cloud/$basearch/openstack-pike/ http://mirrors.cloud.aliyuncs.com/centos/7.5.1804/cloud/$basearch/openstack-pike/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7


------內容說明--------
[標題] 
name=名字 
failovermethode 有兩個選項roundrobin和priority,意思分別是有多個url可供選擇時,yum選擇的次序,roundrobin是隨機選擇,
          若是鏈接失 敗則使用下一個,依次循環,priority則根據url的次序從第一個開始。若是不指明,默認是roundrobin。
baseurl=全部rpm包所在的路徑能夠是網站也能夠是本地目錄分三種格式ftp:// http:// file:// 
enabled=0/1這個源是否啓用 0不啓用1啓用 
gpgcheck=0/1這個包是否作key校驗 
gpgkey=file:///etc/pki/rpm-gpg/這個目錄下的key文件(若是gpgcheck=0就不須要這一項)
------我是內容說明底線---------




#清空倉庫緩存
yum clean all
#強制刪除緩存文件索引
rm -rf /var/cache/yum/*
#從新建立新的緩存索引文件
yum makecache

#建立後檢查以下圖

 下載全部rpm包及其相關包:sql

yumdownloader * --destdir=/tmp/rpms/

下載完成後檢查是否下載完成。vim

若是不想下載,在有網的狀況下可使用yum在線安裝,若是不想在線安裝,須要離線安裝,能夠將下載下來的rpm包打包成爲本地源進行使用。centos

 

------------------下面是製做離線yum源-------------------promise

方式1、將下載下的多個rpm包放置在一個臨時目錄  如/tmp/rpms緩存

[root@controller yum.repos.d]# cat cloud.repo
[cloud]
name=cloud
baseurl=file:///tmp/rpms/
enabled=1
gpgcheck=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
[root@controller yum.repos.d]# ls
CentOS-Base.repo.bak cloud.repo cloud.repo.bak
#清空倉庫緩存
yum clean all
#強制刪除緩存文件索引
rm -rf /var/cache/yum/*
#從新建立新的緩存索引文件
yum makecache
上面這個命令可能會出現以下問題:
[root@controller yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
file:///tmp/rpms/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /tmp/rpms/repodata/repomd.xml"
Trying other mirror.


 One of the configured repositories failed (cloud),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=cloud ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable cloud
        or
            subscription-manager repos --disable=cloud

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=cloud.skip_if_unavailable=true

failure: repodata/repomd.xml from cloud: [Errno 256] No more mirrors to try.
file:///tmp/rpms/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /tmp/rpms/repodata/repomd.xml"

問題緣由是這個目錄下雖然有不少的rpm 包,可是yum工具不會憑空去使用這些rpm包。因此須要使用一個工具createrepo(若是沒有默認安裝能夠下載對應版本安裝)curl

來建立repo索引。工具

[root@controller yum.repos.d]# createrepo /tmp/rpms/*
Error: Only one directory allowed per run.
Usage: genpkgmetadata.py [options]

You have new mail in /var/spool/mail/root
[root@controller yum.repos.d]# createrepo /tmp/rpms/
Spawning worker 0 with 1590 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

這樣就可使用yum來使用離線倉庫了網站

再試一下:this

yum clean all && yum makecache  就可使用這個離線倉庫了(以下)

[root@controller yum.repos.d]# yum clean all && yum makecache
Loaded plugins: fastestmirror, langpacks
Cleaning repos: cloud
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
cloud                                                                     | 2.9 kB  00:00:00     
(1/3): cloud/filelists_db                                                 | 1.8 MB  00:00:00     
(2/3): cloud/other_db                                                     | 325 kB  00:00:00     
(3/3): cloud/primary_db                                                   | 670 kB  00:00:00     
Metadata Cache Created
相關文章
相關標籤/搜索