前言

参考文章:https://linux.cn/article-7937-1.html

在参考文章的基础上进行总结。

使用download-only插件实现

首先我们可以使用downloadonly插件来实现这个目标,但是前提我们需要先安装这个插件:

yum install yum-plugin-downloadonly

备注:安装这个插件的时候,请注意CentOS-Base.repo不要移除,如果将CentOS-Base.repo移除,使用CentOS-Media.repo这个挂载的镜像仓库文件,那么就会无法搜索到这个插件,因为这个插件应该是从网络上下载下来的。

接下来就可以使用如下命令下载rpm包而不安装:

yum install --downloadonly <package-name>

使用上述命令,会默认将rpm下载到/var/cache/yum/目录下,具体参数参见/etc/yum.conf文件:

[root@ambari1 hzhiping]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever   # 默认保存rpm的地址
keepcache=1    # 是否开启保存?1为开启,0为关闭
debuglevel=
logfile=/var/log/yum.log
exactarch=
obsoletes=
gpgcheck=
plugins=
installonly_limit=
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

当然,可以指定目录,如下所示:

yum install --downloadonly  --downloaddir=/tmp <package-name>

这样子在/tmp目录下就会看到了,如果不加/表示的是相对路径,会在当前目录创建一个tmp目录,然后保存在tmp目录下。

另外也可以一次性下载多个包,格式如下:

yum install --downloadonly --downloaddir=/tmp <package-name> <package-name>

使用yumdownloader实现

“yumdownloader” 是一款简单,但是却十分有用的命令行工具,它可以一次性下载任何 RPM 软件包及其所有依赖包。

要使用这款工具,首先我们需要安装yum-utils,命令如下:

yum install -y yum-utils

一旦下载好了,我们就能够使用yumdownloader命令去下载相关的rpm包了,以下是yumdownloader命令的帮助文档:

[root@ambari1 hzhiping]# yumdownloader --help
Loaded plugins: fastestmirror
Usage: "yumdownloader [options] package1 [package2] [package..]

Options:
  Plugin Options:

  Yum Base Options:
    -h, --help          show this help message and exit
    -t, --tolerant      be tolerant of errors
    -C, --cacheonly     run entirely from system cache, don't update cache
    -c [config file], --config=[config file]
                        config file location
    -R [minutes], --randomwait=[minutes]
                        maximum command wait time
    -d [debug level], --debuglevel=[debug level]
                        debugging output level
    --showduplicates    show duplicates, in repos, in list/search commands
    -e [error level], --errorlevel=[error level]
                        error output level
    --rpmverbosity=[debug level name]
                        debugging output level for rpm
    -q, --quiet         quiet operation
    -v, --verbose       verbose operation
    -y, --assumeyes     answer yes for all questions
    --assumeno          answer no for all questions
    --version           show Yum version and exit
    --installroot=[path]
                        set install root
    --enablerepo=[repo]
                        enable one or more repositories (wildcards allowed)
    --disablerepo=[repo]
                        disable one or more repositories (wildcards allowed)
    -x [package], --exclude=[package]
                        exclude package(s) by name or glob
    --disableexcludes=[repo]
                        disable exclude from main, for a repo or for
                        everything
    --disableincludes=[repo]
                        disable includepkgs for a repo or for everything
    --obsoletes         enable obsoletes processing during updates
    --noplugins         disable Yum plugins
    --nogpgcheck        disable gpg signature checking
    --disableplugin=[plugin]
                        disable plugins by name
    --enableplugin=[plugin]
                        enable plugins by name
    --skip-broken       skip packages with depsolving problems
    --color=COLOR       control whether color is used
    --releasever=RELEASEVER
                        set value of $releasever in yum config and repo files
    --downloadonly      don't update, just download
    --downloaddir=DLDIR
                        specifies an alternate directory to store packages
    --setopt=SETOPTS    set arbitrary config and repo options
    --bugfix            Include bugfix relevant packages, in updates
    --security          Include security relevant packages, in updates
    --advisory=ADVS, --advisories=ADVS
                        Include packages needed to fix the given advisory, in
                        updates
    --bzs=BZS           Include packages needed to fix the given BZ, in
                        updates
    --cves=CVES         Include packages needed to fix the given CVE, in
                        updates
    --sec-severity=SEVS, --secseverity=SEVS
                        Include security relevant packages matching the
                        severity, in updates

  yumdownloader options:
    --destdir=DESTDIR   destination directory (defaults to current directory)   # 指定下载的目录
    --urls              just list the urls it would download instead of
                        downloading
    --resolve           resolve dependencies and download required packages     # 下载该rpm相关的依赖包
    --source            operate on source packages
    --archlist=ARCHLIST
                        only download packages of certain architecture(s)
[root@ambari1 hzhiping]#

比如我们下载vim-enhanced及其依赖包:

坚壁清野

CentOS 7设置yum仅仅下载rpm不安装总结的更多相关文章

  1. 如何使用yum来下载RPM包而不进行安装

    如何使用yum来下载RPM包而不进行安装 2015-03-23 13:15 theo-l译 linux.cn 字号:T | T yum是基于Red Hat的系统(如CentOS.Fedora.RHEl ...

  2. 【转】用yum只下载rpm包而不安装

    转自:http://liucheng.name/1950/ CentOS用yum安装软件是非常方便的,有时,我们只需要下载其中的rpm包,而不直接安装时咋办呢? 一般情况下,yum是不提供只下载的功能 ...

  3. Yum自动下载RPM包及其所有依赖的包

    前几天我尝试去创建一个仅包含我们经常在 CentOS 7 下使用的软件的本地仓库.当然,我们可以使用 curl 或者 wget 下载任何软件包,然而这些命令并不能下载要求的依赖软件包.你必须去花一些时 ...

  4. 【Linux】用yum来下载rpm,而不安装

    方法一:yum yum命令本身就可以用来下载一个RPM包,标准的yum命令提供了--downloadonly(只下载)的选项来达到这个目的. $ sudo yum install --download ...

  5. Linux yum如何下载rpm包到本地

    下载前先安装一个小插件 [root@wang yum.repos.d]# yum install -y yum-plugin-downloadonly 安装一个包的同时 加上 yum install ...

  6. 使用yum来下载RPM包而不进行安装

    1. 安装yum-downloadonly. yum-utils 或 yum-plugin-downloadonly 软件包 (RHEL5) # yum install yum-downloadonl ...

  7. yum 下载rpm包 安装rpm包依赖关系

    方法一:yumdownloader 工具 1.安装工具包 yum install yum-utils -y 2.下载一个RPM包 yumdownloader <package-name> ...

  8. centos7用rpm安装mysql5.7【初始用yum安装发现下载非常慢,就考虑本地用迅雷下载rpm方式安装】

    1.下载 4个rpm包 mysql-community-client-5.7.26-1.el7.x86_64.rpmmysql-community-common-5.7.26-1.el7.x86_64 ...

  9. yum仅下载RPM包不安装

    http://www.ttlsa.com/linux/howto-yum-download-rpm-without-install/

随机推荐

  1. django中云存储静态文件

    Django自带文件存储系统存储在本地文件夹,如果我们将文件存储在云端,需要自定义文件存储系统. 自定义文件存储系统需要继承django.core.files.storage.Storage from ...

  2. 服务程序在c#中的写法

    1.在VS.NET2003中新建一个WINDOWS服务程序的项目WinSrv_A. 2.更改SERVICE1.CS属性SERVICENAME为你所要建立的服务名称,在服务管理器->名称中你可以看 ...

  3. ajax与axios

  4. KiCad EDA 原理图库的最佳实践

    KiCad EDA 原理图库的最佳实践 由于有 Alias 别名元件,可以不用一个每一个元件都有一个元件. 对每种元件类型建议一个元件库. 因为 Value 和 元件名是一样的,所以元件名要尽可能的简 ...

  5. SoapUI接口测试-验签值处理-调用java的加密jar包

    转载自:https://www.jianshu.com/p/7c672426a165 一. 背景: 调用接口时有个请求参数是对请求入参按一定规则进行加密生成的验签值,每次不同参数的请求生成唯一的验签值 ...

  6. 华硕ASUSPRO P5440UA笔记本电脑安装驱动

    领了一台公司的办公笔记本,按照套路重装了系统(win10),后面发现悲剧了 采坑1: 从华硕通过型号搜索下来的无线网卡(WIFI) 驱动无法安装(双击启动没有反映) 解决:通过设备Id上google搜 ...

  7. C# .net mvc web api 返回 json 内容,过滤值为null的属性

    在WebApiConfig.Register 中增加一段 #region 过滤值为null的属性 //json 序列化设置 GlobalConfiguration.Configuration.Form ...

  8. JavaScript获取元素CSS计算后的样式

    原文链接https://www.w3ctech.com/topic/40 我们在开发过程中,有时候需要根据元素已有样式来实现一些效果,那我们应该如何通过JavaScript来获取一个元素计算后的样式值 ...

  9. centos7安装rabbitmq3.7.9

    感谢此兄: https://blog.51cto.com/huwei555/2341513?source=dra  (centos7 安装rabbitmq 3.7) 以root用户登录.cd /hom ...

  10. Promise.all处理多个异步请求

    一个前台页面需要请求2个rest接口获取数据,一个用于解析文件获取列名,一个查询数据库获得列值. 有很低的概率页面显示为空,刷新可能就有显示了. 使用Promise.all就解决了上面的问题,2部分数 ...