0%

yum 下载全量依赖rpm包及离线安装

简述

通常生产环境由于安全原因都无法访问互联网。此时就需要进行离线安装,主要有两种方式:源码编译、rpm包安装。源码编译耗费时间长且缺乏编译环境,所以一般都选择使用离线rpm包安装

环境

CentOS 7.2

查看依赖包

可以使用yum deplist命令来查找rpm包的依赖列表。例如,要查找perl的依赖包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[xxxx@xxxx perl]$ yum deplist perl
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.yun-idc.com
* extras: mirrors.aliyun.com
* updates: mirrors.ustc.edu.cn
软件包:perl.x86_64 4:5.16.3-295.el7
依赖:libc.so.6(GLIBC_2.14)(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libcrypt.so.1()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libdl.so.2()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libgdbm.so.4()(64bit)
provider: gdbm.x86_64 1.10-8.el7
依赖:libgdbm_compat.so.4()(64bit)
provider: gdbm.x86_64 1.10-8.el7
依赖:libm.so.6()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libm.so.6(GLIBC_2.2.5)(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libnsl.so.1()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libperl.so()(64bit)
provider: perl-libs.x86_64 4:5.16.3-295.el7
依赖:libpthread.so.0()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libresolv.so.2()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:libutil.so.1()(64bit)
provider: glibc.x86_64 2.17-307.el7.1
依赖:perl(Carp)
provider: perl-Carp.noarch 1.26-244.el7
依赖:perl(Cwd)
provider: perl-PathTools.x86_64 3.40-5.el7
依赖:perl(Exporter)
provider: perl-Exporter.noarch 5.68-3.el7
依赖:perl(File::Path)
provider: perl-File-Path.noarch 2.09-2.el7
依赖:perl(File::Spec)
provider: perl-PathTools.x86_64 3.40-5.el7
依赖:perl(File::Spec::Functions)
provider: perl-PathTools.x86_64 3.40-5.el7
依赖:perl(File::Spec::Unix)
provider: perl-PathTools.x86_64 3.40-5.el7
依赖:perl(File::Temp)
provider: perl-File-Temp.noarch 0.23.01-3.el7
依赖:perl(Filter::Util::Call)
provider: perl-Filter.x86_64 1.49-3.el7
依赖:perl(Getopt::Long)
provider: perl-Getopt-Long.noarch 2.40-3.el7
依赖:perl(Pod::Simple::Search)
provider: perl-Pod-Simple.noarch 1:3.28-4.el7
依赖:perl(Pod::Simple::XHTML)
provider: perl-Pod-Simple.noarch 1:3.28-4.el7
依赖:perl(Scalar::Util)
provider: perl-Scalar-List-Utils.x86_64 1.27-248.el7
依赖:perl(Scalar::Util) >= 1.10
provider: perl-Scalar-List-Utils.x86_64 1.27-248.el7
依赖:perl(Socket)
provider: perl-Socket.x86_64 2.010-5.el7
依赖:perl(Socket) >= 1.3
provider: perl-Socket.x86_64 2.010-5.el7
依赖:perl(Storable)
provider: perl-Storable.x86_64 2.45-3.el7
依赖:perl(Time::HiRes)
provider: perl-Time-HiRes.x86_64 4:1.9725-3.el7
依赖:perl(Time::Local)
provider: perl-Time-Local.noarch 1.2300-2.el7
依赖:perl(constant)
provider: perl-constant.noarch 1.27-2.el7
依赖:perl(threads)
provider: perl-threads.x86_64 1.87-4.el7
依赖:perl(threads::shared)
provider: perl-threads-shared.x86_64 1.43-6.el7
依赖:perl-libs
provider: perl-libs.x86_64 4:5.16.3-295.el7
provider: perl-libs.i686 4:5.16.3-295.el7
依赖:perl-libs = 4:5.16.3-295.el7
provider: perl-libs.x86_64 4:5.16.3-295.el7
provider: perl-libs.i686 4:5.16.3-295.el7
依赖:perl-macros
provider: perl-macros.x86_64 4:5.16.3-295.el7
依赖:rtld(GNU_HASH)
provider: glibc.x86_64 2.17-307.el7.1
provider: glibc.i686 2.17-307.el7.1

下载依赖包

方案一(推荐):repotrack

1
2
3
4
5
# 安装yum-utils
[root@xxxx ~]# yum -y install yum-utils

# 下载perl全量依赖包
[root@xxxx ~]# repotrack perl

方案二:yumdownloader

1
2
3
4
5
# 安装yum-utils
[root@xxxx ~]# yum -y install yum-utils

# 下载 perl 依赖包
$ yumdownloader --resolve --destdir=/tmp perl

参数说明:

  • destdir:指定rpm包下载目录(不指定,默认为当前目录)
  • resolve:下载依赖的rpm包

仅会将主软件包和基于你现在的操作系统所缺少的依赖关系包一并下载。

离线安装rpm

1
rpm -Uvh --force --nodeps *.rpm