CentOS7 只下载安装包不安装
参考文档
yum安装本地rpm软件方案详解 https://www.jb51.net/article/132305.htm
createrepo
CentOS-Media.repo 本地软件源
--downloadonly --downloaddir 只下载不安装
# 关闭网络软件源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bk
# 开启本地软件源
编辑 CentOS-Media.repo
vim /etc/yum.repos.d/CentOS-Media.repo
通过 baseurl 指定本地 rpm 包所在的目录。
baseurl=file:////home/user/rpms/
将这个源设置为开启
enabled=1
这样就可以使yum采用本地源安装软件。
命令
# yum 搜索已安装的软件
[root@localhost mozq]# yum list installed | grep sz
lrzsz.x86_64 0.12.20-36.el7 installed
# yum 卸载软件
[root@localhost ~]# yum erase lrzsz.x86_64
# yum 只下载安装包到指定位置不安装
[root@localhost ~]# yum install lrzsz.x86_64 --downloadonly --downloaddir=/root/package
# 参数
--downloadonly don't update, just download 只下载
--downloaddir=DLDIR specifies an alternate directory to store packages 指定安装包保存目录
# rpm 安装本地安装包
[root@localhost mozq]# ll /root/package/
total 80
-rw-r--r--. 1 root root 79376 Jul 4 2014 lrzsz-0.12.20-36.el7.x86_64.rpm
[root@localhost mozq]# rpm -ivh /root/package/lrzsz-0.12.20-36.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:lrzsz-0.12.20-36.el7 ################################# [100%]
实战
--downloadonly don't update, just download
--downloaddir=DLDIR specifies an alternate directory to store packages
[root@localhost ~]# yum install lrzsz.x86_64 --downloadonly --downloaddir=/root/package
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.neusoft.edu.cn
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-36.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==================================================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================================================
Installing:
lrzsz x86_64 0.12.20-36.el7 base 78 k
Transaction Summary
==================================================================================================================================================================================
Install 1 Package
Total download size: 78 k
Installed size: 181 k
Background downloading packages, then exiting:
lrzsz-0.12.20-36.el7.x86_64.rpm | 78 kB 00:00:00
exiting because "Download Only" specified
# 安装包被下载到指定目录中,并且没有安装
[root@localhost ~]# ll /root/package
total 80
-rw-r--r--. 1 root root 79376 Jul 4 2014 lrzsz-0.12.20-36.el7.x86_64.rpm