如何使用yum命令下载RPM软件包而不在Linux上安装
时间:2020-01-09 10:44:15 来源:igfitidea点击:
如何在CentOS Enterprise Linux服务器5.x或者RHEL 5.x系统下使用yum命令下载RPM软件包?
您需要安装名为yum-downloadonly
的插件。
该插件向yum添加了一个downloadonly标志,因此yum将仅下载软件包,而不安装/更新它们。
该插件支持以下选项:
downloadonly
:不更新,仅下载rpm文件downloaddir =/path/to/dir
:指定备用目录来存储软件包,例如/tmp
请注意,以下说明仅在CentOS服务器上经过测试,但可以与RHN和RHEL一起使用而没有任何问题。
如何安装yum-downloadonly插件?
输入以下命令以安装插件,执行:
# yum install yum-downloadonly
输出示例:
Loading "fastestmirror" plugin Loading "security" plugin Loading mirror speeds from cached hostfile * base: centos.mirrors.tds.net * updates: mirror.myriadnetwork.com * addons: mirrors.gigenet.com * extras: holmes.umflint.edu Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package yum-downloadonly.noarch 0:1.1.10-9.el5.centos set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: yum-downloadonly noarch 1.1.10-9.el5.centos base 9.0 k Transaction Summary ============================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 9.0 k Is this ok [y/N]: y Downloading Packages: (1/1): yum-downloadonly-1 100% |=========================| 9.0 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: yum-downloadonly ######################### [1/1] Installed: yum-downloadonly.noarch 0:1.1.10-9.el5.centos Complete!
如何仅从RHN或者CentOS镜像下载RPM软件包而不安装?
下载httpd软件包,但不要安装/更新,请执行:
# yum update httpd -y --downloadonly
默认情况下,软件包将通过下载并存储在/var/cache/yum /目录中。
但是,您可以指定一个备用目录来存储诸如/opt之类的软件包,执行:
# yum update httpd -y --downloadonly --downloaddir=/opt
输出示例:
yum install httpd -y --downloadonly Loading "downloadonly" plugin Loading "fastestmirror" plugin Loading "security" plugin Loading mirror speeds from cached hostfile * base: centos.mirrors.mypsh.com * updates: mirror.steadfast.net * addons: mirrors.gigenet.com * extras: holmes.umflint.edu Setting up Install Process Parsing package install arguments Resolving Dependencies --> Running transaction check ---> Package httpd.i386 0:2.2.3-11.el5_1.centos.3 set to be updated filelists.xml.gz 100% |=========================| 2.8 MB 00:03 filelists.xml.gz 100% |=========================| 681 kB 00:11 filelists.xml.gz 100% |=========================| 122 kB 00:00 filelists.xml.gz 100% |=========================| 150 B 00:00 --> Finished Dependency Resolution Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: httpd i386 2.2.3-11.el5_1.centos.3 base 1.1 M Transaction Summary ============================================================================= Install 1 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 1.1 M Downloading Packages: (1/1): httpd-2.2.3-11.el5 100% |=========================| 1.1 MB 00:01 exiting because --downloadonly specified
要查看下载的文件,请执行:
# ls -l /opt/*.rpm
输出示例:
-rw-r--r-- 1 root root 1116426 Jan 17 03:36 /opt/httpd-2.2.3-11.el5_1.centos.3.i386.rpm -rw-r--r-- 1 root root 83452 Oct 2 2007 /opt/lighttpd-fastcgi-1.4.18-1.el5.rf.i386.rpm -rw-r--r-- 1 root root 635045 Oct 20 2007 /opt/psad-2.1-1.i386.rpm
方法2:yum-utils.noarch包
yum-utils是yum软件包管理器的实用程序和示例的集合。
它包含不同作者的实用程序,这些实用程序使yum更容易使用,功能更强大。
这些工具包括:debuginfo-install,package-cleanup,repoclosure,repodiff,repo-graph,repomanage,repoquery,repo-rss,reposync,repotrack,verifytree,yum-builddep,yum-complete-transaction,yumdownloader,yum-debug-转储和yum-groups-manager。
# yum -y install yum-utils.noarch
现在使用" yumdownloader命令",它是一个从Yum存储库下载RPM的程序。
输入以下命令以下载httpd rpm文件:
# yumdownloader httpd
输出示例:
Loaded plugins: rhnplugin httpd-2.2.3-31.el5_4.2.x86_64.rpm | 1.2 MB 00:00
如何提取下载的RPM文件?
执行命令,如下所示:
# rpm2cpio httpd-2.2.3-31.el5_4.2.x86_64.rpm | cpio -idmv