使用Downloadonly 插件下载 RPM 软件包及其所有依赖包以及利用yum进行所需要的rpm包下载,但在CentOS中没有安装yum相应工具的情况下需要先安装yun工具
建议:先修改yum源,一般我愿意使用阿里巴巴的源,修改yum源之前先做好系统原有文件的备份,避免出错可以恢复(这是个好习惯一定要注意,玩Linux系统的都懂)
备份源文件:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
修改yum源(将默认的源更换为ailiyun源):
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
附加上国内yum源(个人使用这个都能一般rpm都比较全都能下载):
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo (阿里)
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo (网易)
# yum install yum-plugin-downloadonly {使用root权限用户执行该命令}
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.4.3-161.el7.centos will be updated
---> Package yum.noarch 0:3.4.3-168.el7.centos will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Updating:
yum noarch 3.4.3-168.el7.centos base 1.2 M
Transaction Summary
===============================================================================================
Upgrade 1 Package
Total size: 1.2 M
Is this ok [y/d/N]: y {选择y}
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Updating : yum-3.4.3-168.el7.centos.noarch 1/2
Cleanup : yum-3.4.3-161.el7.centos.noarch 2/2
Verifying : yum-3.4.3-168.el7.centos.noarch 1/2
Verifying : yum-3.4.3-161.el7.centos.noarch 2/2
Updated:
yum.noarch 0:3.4.3-168.el7.centos
Complete! {工具安装完成}
yum install yum-utils工具安装
# yum install yum-utils {
使用root权限用户执行该命令}
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-50.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Updating:
yum-utils noarch 1.1.31-54.el7_8 base 122 k
Transaction Summary
===============================================================================================
Upgrade 1 Package
Total size: 122 k
Is this ok [y/d/N]: y {选择y}
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : yum-utils-1.1.31-54.el7_8.noarch 1/2
Cleanup : yum-utils-1.1.31-50.el7.noarch 2/2
Verifying : yum-utils-1.1.31-54.el7_8.noarch 1/2
Verifying : yum-utils-1.1.31-50.el7.noarch 2/2
Updated:
yum-utils.noarch 0:1.1.31-54.el7_8
Complete!
2个yum工具安装完后就可以进行下载rpm包了两种方式:
1、yum在线安装
2、yumdownloader 下载rpm包
例子:直接在线安装
# yum install lvm2 {
使用root权限用户执行该命令}
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package lvm2.x86_64 7:2.02.180-8.el7 will be updated
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> Processing Dependency: lvm2-libs = 7:2.02.187-6.el7_9.5 for package: 7:lvm2-2.02.187-6.el7_9.5.x86_64
--> Running transaction check
---> Package lvm2-libs.x86_64 7:2.02.180-8.el7 will be updated
---> Package lvm2-libs.x86_64 7:2.02.187-6.el7_9.5 will be an update
--> Processing Dependency: device-mapper-event = 7:1.02.170-6.el7_9.5 for package: 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64
--> Running transaction check
---> Package device-mapper-event.x86_64 7:1.02.149-8.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
--> Processing Dependency: device-mapper = 7:1.02.170-6.el7_9.5 for package: 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.149-8.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.149-8.el7 for package: 7:device-mapper-libs-1.02.149-8.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.170-6.el7_9.5 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.149-8.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.149-8.el7 will be updated
---> Package device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================
Package Arch Version Repository Size
===============================================================================================
Updating:
lvm2 x86_64 7:2.02.187-6.el7_9.5 updates 1.3 M
Updating for dependencies:
device-mapper x86_64 7:1.02.170-6.el7_9.5 updates 297 k
device-mapper-event x86_64 7:1.02.170-6.el7_9.5 updates 192 k
device-mapper-event-libs x86_64 7:1.02.170-6.el7_9.5 updates 192 k
device-mapper-libs x86_64 7:1.02.170-6.el7_9.5 updates 325 k
lvm2-libs x86_64 7:2.02.187-6.el7_9.5 updates 1.1 M
Transaction Summary
===============================================================================================
Upgrade 1 Package (+5 Dependent packages)
Total size: 3.4 M
Is this ok [y/d/N]: y {选择y}
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 1/12
Updating : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 2/12
Updating : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 3/12
Updating : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 4/12
Updating : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 5/12
Updating : 7:lvm2-2.02.187-6.el7_9.5.x86_64 6/12
Cleanup : 7:lvm2-2.02.180-8.el7.x86_64 7/12
Cleanup : 7:lvm2-libs-2.02.180-8.el7.x86_64 8/12
Cleanup : 7:device-mapper-event-1.02.149-8.el7.x86_64 9/12
Cleanup : 7:device-mapper-event-libs-1.02.149-8.el7.x86_64 10/12
Cleanup : 7:device-mapper-1.02.149-8.el7.x86_64 11/12
Cleanup : 7:device-mapper-libs-1.02.149-8.el7.x86_64 12/12
Verifying : 7:device-mapper-event-1.02.170-6.el7_9.5.x86_64 1/12
Verifying : 7:lvm2-libs-2.02.187-6.el7_9.5.x86_64 2/12
Verifying : 7:device-mapper-1.02.170-6.el7_9.5.x86_64 3/12
Verifying : 7:device-mapper-event-libs-1.02.170-6.el7_9.5.x86_64 4/12
Verifying : 7:lvm2-2.02.187-6.el7_9.5.x86_64 5/12
Verifying : 7:device-mapper-libs-1.02.170-6.el7_9.5.x86_64 6/12
Verifying : 7:lvm2-2.02.180-8.el7.x86_64 7/12
Verifying : 7:device-mapper-event-1.02.149-8.el7.x86_64 8/12
Verifying : 7:lvm2-libs-2.02.180-8.el7.x86_64 9/12
Verifying : 7:device-mapper-1.02.149-8.el7.x86_64 10/12
Verifying : 7:device-mapper-libs-1.02.149-8.el7.x86_64 11/12
Verifying : 7:device-mapper-event-libs-1.02.149-8.el7.x86_64 12/12
Updated:
lvm2.x86_64 7:2.02.187-6.el7_9.5
Dependency Updated:
device-mapper.x86_64 7:1.02.170-6.el7_9.5
device-mapper-event.x86_64 7:1.02.170-6.el7_9.5
device-mapper-event-libs.x86_64 7:1.02.170-6.el7_9.5
device-mapper-libs.x86_64 7:1.02.170-6.el7_9.5
lvm2-libs.x86_64 7:2.02.187-6.el7_9.5
Complete!例子:通过yumdownloader下载rpm包
首先创建一个文件夹(方便查找已经下载rpm包,个人习惯不建立在当前文件目录下载也可)
# mkdir lvm2_rpm
进入到建立好的文件目录
# cd /home/rc/lvm2_rpm
# yumdownloader lvm2 --resolve
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
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 | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
--> Running transaction check
---> Package lvm2.x86_64 7:2.02.187-6.el7_9.5 will be reinstalled
--> Finished Dependency Resolution
lvm2-2.02.187-6.el7_9.5.x86_64.rpm | 1.3 MB 00:00:19
# ll {通过ll命令查看,lvm2的rpm包已经下载完毕}
total 1356
-rw-r--r--. 1 root root 1387424 Apr 29 2021 lvm2-2.02.187-6.el7_9.5.x86_64.rpm
文章来源:https://www.toymoban.com/news/detail-684666.html
以上2个例子供参考,以此类推缺少的rpm包可以用这个方式进行下载。文章来源地址https://www.toymoban.com/news/detail-684666.html
到了这里,关于解决没有rpm的困扰 CentOS7下载RPM及其所有的依赖包的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!