1 修改/etc/yum.conf的keepcache=1
[[email protected] packages]# vi /etc/yum.conf keepcache=1 |
2 安装yum-utils包
[[email protected] packages]# rpm -qa |grep yum-utils [[email protected] packages]# yum -y install yum-utils* 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com base | 3.6 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 updates/7/x86_64/primary_db | 5.0 MB 00:00:00 正在解决依赖关系 --> 正在检查事务 ---> 软件包 yum-utils.noarch.0.1.1.31-50.el7 将被 安装 --> 正在处理依赖关系 python-kitchen,它被软件包 yum-utils-1.1.31-50.el7.noarch 需要 --> 正在处理依赖关系 libxml2-python,它被软件包 yum-utils-1.1.31-50.el7.noarch 需要 --> 正在检查事务 ---> 软件包 libxml2-python.x86_64.0.2.9.1-6.el7_2.3 将被 安装 ---> 软件包 python-kitchen.noarch.0.1.1.1-5.el7 将被 安装 --> 正在处理依赖关系 python-chardet,它被软件包 python-kitchen-1.1.1-5.el7.noarch 需要 --> 正在检查事务 ---> 软件包 python-chardet.noarch.0.2.2.1-1.el7_1 将被 安装 --> 解决依赖关系完成 依赖关系解决 =========================================================================================================================== Package 架构 版本 源 大小 =========================================================================================================================== 正在安装: yum-utils noarch 1.1.31-50.el7 base 121 k 为依赖而安装: libxml2-python x86_64 2.9.1-6.el7_2.3 base 247 k python-chardet noarch 2.2.1-1.el7_1 base 227 k python-kitchen noarch 1.1.1-5.el7 base 267 k 事务概要 =========================================================================================================================== 安装 1 软件包 (+3 依赖软件包) 总下载量:861 k 安装大小:4.3 M Downloading packages: (1/4): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm | 247 kB 00:00:00 (2/4): python-chardet-2.2.1-1.el7_1.noarch.rpm | 227 kB 00:00:00 (3/4): python-kitchen-1.1.1-5.el7.noarch.rpm | 267 kB 00:00:00 (4/4): yum-utils-1.1.31-50.el7.noarch.rpm | 121 kB 00:00:00 --------------------------------------------------------------------------------------------------------------------------- 总计 1.9 MB/s | 861 kB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction 正在安装 : python-chardet-2.2.1-1.el7_1.noarch 1/4 正在安装 : python-kitchen-1.1.1-5.el7.noarch 2/4 正在安装 : libxml2-python-2.9.1-6.el7_2.3.x86_64 3/4 正在安装 : yum-utils-1.1.31-50.el7.noarch 4/4 验证中 : libxml2-python-2.9.1-6.el7_2.3.x86_64 1/4 验证中 : python-kitchen-1.1.1-5.el7.noarch 2/4 验证中 : yum-utils-1.1.31-50.el7.noarch 3/4 验证中 : python-chardet-2.2.1-1.el7_1.noarch 4/4 已安装: yum-utils.noarch 0:1.1.31-50.el7 作为依赖被安装: libxml2-python.x86_64 0:2.9.1-6.el7_2.3 python-chardet.noarch 0:2.2.1-1.el7_1 python-kitchen.noarch 0:1.1.1-5.el7 完毕! [[email protected] packages]# rpm -ql yum-utils /etc/bash_completion.d /etc/bash_completion.d/yum-utils.bash /usr/bin/debuginfo-install /usr/bin/find-repos-of-install /usr/bin/needs-restarting /usr/bin/package-cleanup /usr/bin/repo-graph /usr/bin/repo-rss /usr/bin/repoclosure /usr/bin/repodiff /usr/bin/repomanage /usr/bin/repoquery /usr/bin/reposync /usr/bin/repotrack /usr/bin/show-changed-rco /usr/bin/show-installed /usr/bin/verifytree /usr/bin/yum-builddep /usr/bin/yum-config-manager /usr/bin/yum-debug-dump /usr/bin/yum-debug-restore /usr/bin/yum-groups-manager /usr/bin/yumdownloader /usr/lib/python2.7/site-packages/yumutils /usr/lib/python2.7/site-packages/yumutils/__init__.py /usr/lib/python2.7/site-packages/yumutils/__init__.pyc /usr/lib/python2.7/site-packages/yumutils/__init__.pyo /usr/lib/python2.7/site-packages/yumutils/i18n.py /usr/lib/python2.7/site-packages/yumutils/i18n.pyc /usr/lib/python2.7/site-packages/yumutils/i18n.pyo /usr/sbin/yum-complete-transaction /usr/sbin/yumdb /usr/share/doc/yum-utils-1.1.31 /usr/share/doc/yum-utils-1.1.31/COPYING /usr/share/doc/yum-utils-1.1.31/README /usr/share/doc/yum-utils-1.1.31/yum-util-cli-template /usr/share/locale/da/LC_MESSAGES/yum-utils.mo /usr/share/man/man1/debuginfo-install.1.gz /usr/share/man/man1/find-repos-of-install.1.gz /usr/share/man/man1/needs-restarting.1.gz /usr/share/man/man1/package-cleanup.1.gz /usr/share/man/man1/repo-graph.1.gz /usr/share/man/man1/repo-rss.1.gz /usr/share/man/man1/repoclosure.1.gz /usr/share/man/man1/repodiff.1.gz /usr/share/man/man1/repomanage.1.gz /usr/share/man/man1/repoquery.1.gz /usr/share/man/man1/reposync.1.gz /usr/share/man/man1/repotrack.1.gz /usr/share/man/man1/show-changed-rco.1.gz /usr/share/man/man1/show-installed.1.gz /usr/share/man/man1/verifytree.1.gz /usr/share/man/man1/yum-builddep.1.gz /usr/share/man/man1/yum-config-manager.1.gz /usr/share/man/man1/yum-debug-dump.1.gz /usr/share/man/man1/yum-debug-restore.1.gz /usr/share/man/man1/yum-groups-manager.1.gz /usr/share/man/man1/yum-utils.1.gz /usr/share/man/man1/yumdownloader.1.gz #可以看到yumdownloade这个工具是由yum-utils这个软件安装生成的! /usr/share/man/man8/yum-complete-transaction.8.gz /usr/share/man/man8/yumdb.8.gz |
3 使用yumdownloader 下载
[[email protected] packages]# yumdownloader centos-release-openstack-rocky 已加载插件:fastestmirror Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com centos-release-openstack-rocky-1-1.el7.centos.noarch.rpm | 5.2 kB 00:00:00 [[email protected] packages]# ls centos-release-openstack-rocky-1-1.el7.centos.noarch.rpm python-kitchen-1.1.1-5.el7.noarch.rpm libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm yum-utils-1.1.31-50.el7.noarch.rpm python-chardet-2.2.1-1.el7_1.noarch.rpm [[email protected] packages]# pwd /var/cache/yum/x86_64/7/base/packages |
注意,下载软件及依赖包需要加参数
为了根据所有依赖性下载软件包,我们使用 --resolve 参数: yumdownloader --resolve httpd 为了将软件下载到一个特定的目录下,我们使用 --destdir 参数: yumdownloader --resolve --destdir=/root/mypackages/ httpd 或者 yumdownloader --resolve --destdir /root/mypackages/ httpd |
原文地址:https://www.cnblogs.com/cloud-datacenter/p/12232951.html