打赏
Fork me on GitHub

[原]获取openstack-pike安装包

linux version: CentOS 7.5.1804

#进入仓库配置目录

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包及其相关包:

yumdownloader * --destdir=/tmp/rpms/

下载完成后检查是否下载完成。

如果不想下载,在有网的情况下可以使用yum在线安装,如果不想在线安装,需要离线安装,可以将下载下来的rpm包打包成为本地源进行使用。

 

------------------下面是制作离线yum源-------------------

方式一、将下载下的多个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(如果没有默认安装可以下载对应版本安装)

来创建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来使用离线仓库了

再试一下:

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

 







 

posted @ 2018-08-29 15:57  my_cool2007  阅读(1035)  评论(0编辑  收藏  举报