yum安装并保留依赖包|yum下载依赖包本地保存|yum保存rpm包|yum下载rpm包及依赖包

yum安装并保存依赖包

通常我们在liunx上安装软件时会通过yum或者其他的RPM包管理工具下载,能够方便的解决程序依赖问题,但是在很多情况下,我们在到一个项目环境时无法使用外网,因此没办法通过外网使用yum下载。

那么我们可以先在本地建立一个相同的OS环境,在本地通过yum安装,并且将yum安装时下载的所有依赖以及程序包保存下来,就可以直接在客户环境进行离线安装了。

方法一:修改yum源配置,开启依赖下载的依赖包缓存配置

第一步:修改yum源配置文件,vi /etc/yum.conf

cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
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

将cachedir、keepcache两项配置如下:

cachedir=/var/cache/yum #这是配置为/var/cache/yum是方便后续演示使用,避免不同系统默认保存路径不一致
keepcache=1

配置修改完成后通过yum 安装程序包时就会将下载和被更新的所有依赖以及程序包保存至我们配置的路径(/var/cache/yum)下。

配置项说明:

cachediryum下载的RPM包的缓存目录
keepcache缓存是否保存,1保存,0不保存
debuglevel调试级别(0-10),默认为2
logfileyum的日志文件所在的位置,默认是/var/log/yum.log
exactarch是否只升级和你安装软件包cpu体系一致的包
obsoletes是否允许更新陈旧的RPM包
gpgcheck是否检查GPG(GNU Private Guard)
plugins是否允许使用插件,默认是0不允许
installonly_limit同时安装多少程序包
bugtracker_urlbug追踪路径
distroverpkg当前发行版版本号从哪儿获取
  

 

 

 

 

 

 

 

 

 

 

 

方法二:使用yum命令直接下载对应的依赖包

yum -y install --downloadonly --downloaddir=/home/yum_package wget

参数说明:

--downloadonly 仅下载依赖包不安装

--downloaddir 下载的依赖包保存的文件位置

wget 需要下载的依赖包,这里可以是多个

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值