linux之yum下载rpm包离线安装conntrack-tools

如何下载rpm包,进行离线安装


前言

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

一.yum下载rpm包离线安装方式

​ 首先我们需要在可以上网的服务器上将需要安装软件的rpm离线包下载下来,然后拷贝到不能上网的服务器上安装。以下是几种下载的方法(联网的节点和生产环境的操作系统版本尽量接近,最好一致)

方法一:使用yum 的 downloadonly 插件下载

[root@iZbp1fy7y89tqjvmlp1dvhZ k8s]# yum install conntrack-tools  --downloadonly --downloaddir=/opt/software/InstallPackages/conntrack-tools

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ll
total 268
-rw-r--r-- 1 root root 191000 Apr  4  2020 conntrack-tools-1.4.4-7.el7.x86_64.rpm
-rw-r--r-- 1 root root  18400 Apr  4  2020 libnetfilter_cthelper-1.0.0-11.el7.x86_64.rpm
-rw-r--r-- 1 root root  18212 Apr  4  2020 libnetfilter_cttimeout-1.0.0-7.el7.x86_64.rpm
-rw-r--r-- 1 root root  23584 Aug 11  2017 libnetfilter_queue-1.0.2-2.el7_2.x86_64.rpm

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ls |wc -l
4

使用yumdownloaderrepotrack 这两个命令,必须先下载yum-utils才行。

[root@iZbp1fy7y89tqjvmlp1dvhZ k8s]# yum -y install yum-utils

方法二:使用yumdownloader下载

–resolve 下载依赖包 --destdir 指定下载目录

[root@iZbp1fy7y89tqjvmlp1dvhZ InstallPackages]# yumdownloader –resolve --destdir=/opt/software/InstallPackages/conntrack-tools   conntrack-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No Match for argument –resolve
conntrack-tools-1.4.4-7.el7.x86_64.rpm       | 187 kB  00:00:00 

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ll
total 192
-rw-r--r-- 1 root root 191000 Apr  4  2020 conntrack-tools-1.4.4-7.el7.x86_64.rpm

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ls |wc -l
1

方法三:使用repotrack下载所有依赖

[root@iZbp1fy7y89tqjvmlp1dvhZ k8s]# repotrack conntrack-tools
Downloading acl-2.2.51-15.el7.x86_64.rpm
Downloading audit-libs-2.8.5-4.el7.x86_64.rpm
......
[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ls
acl-2.2.51-15.el7.x86_64.rpm                        libnetfilter_cthelper-1.0.0-11.el7.x86_64.rpm
audit-libs-2.8.5-4.el7.x86_64.rpm                   libnfnetlink-1.0.1-4.el7.x86_64.rpm
autoconf-2.69-11.el7.noarch.rpm                     ...

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ls |wc -l
182

区别:

yumdownloader解决了conntrack-tools的依赖包,但是无法解决依赖包的依赖包;

repotrack不仅解决了conntrack-tools的依赖包,还解决了依赖包和依赖包之间的关系;

二.下载conntrack-tools相关包

​ 首先查看包依赖关系

1.获取依赖关系

[root@x conntrack-tools]# yum deplist conntrack-tools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
package: conntrack-tools.x86_64 1.4.4-7.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-35.el7_9
  dependency: libc.so.6(GLIBC_2.15)(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libdl.so.2()(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libdl.so.2(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libmnl.so.0()(64bit)
   provider: libmnl.x86_64 1.0.3-7.el7
  dependency: libmnl.so.0(LIBMNL_1.0)(64bit)
   provider: libmnl.x86_64 1.0.3-7.el7
  dependency: libnetfilter_conntrack >= 1.0.6
   provider: libnetfilter_conntrack.x86_64 1.0.6-1.el7_3
   provider: libnetfilter_conntrack.i686 1.0.6-1.el7_3
  dependency: libnetfilter_conntrack.so.3()(64bit)
   provider: libnetfilter_conntrack.x86_64 1.0.6-1.el7_3
  dependency: libnetfilter_cthelper.so.0()(64bit)
   provider: libnetfilter_cthelper.x86_64 1.0.0-11.el7
  dependency: libnetfilter_cthelper.so.0(LIBNETFILTER_CTHELPER_1.0)(64bit)
   provider: libnetfilter_cthelper.x86_64 1.0.0-11.el7
  dependency: libnetfilter_cttimeout.so.1()(64bit)
   provider: libnetfilter_cttimeout.x86_64 1.0.0-7.el7
  dependency: libnetfilter_cttimeout.so.1(LIBNETFILTER_CTTIMEOUT_1.0)(64bit)
   provider: libnetfilter_cttimeout.x86_64 1.0.0-7.el7
  dependency: libnetfilter_cttimeout.so.1(LIBNETFILTER_CTTIMEOUT_1.1)(64bit)
   provider: libnetfilter_cttimeout.x86_64 1.0.0-7.el7
  dependency: libnetfilter_queue.so.1()(64bit)
   provider: libnetfilter_queue.x86_64 1.0.2-2.el7_2
  dependency: libnfnetlink.so.0()(64bit)
   provider: libnfnetlink.x86_64 1.0.1-4.el7
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-325.el7_9
   provider: glibc.i686 2.17-325.el7_9
  dependency: systemd
   provider: systemd.x86_64 219-78.el7_9.5

过滤

[root@x  conntrack-tools]#  yum deplist conntrack-tools |grep provider |cut -d : -f 2  |uniq
 bash.x86_64 4.2.46-35.el7_9
 glibc.x86_64 2.17-325.el7_9
 libmnl.x86_64 1.0.3-7.el7
 libnetfilter_conntrack.x86_64 1.0.6-1.el7_3
 libnetfilter_conntrack.i686 1.0.6-1.el7_3
 libnetfilter_conntrack.x86_64 1.0.6-1.el7_3
 libnetfilter_cthelper.x86_64 1.0.0-11.el7
 libnetfilter_cttimeout.x86_64 1.0.0-7.el7
 libnetfilter_queue.x86_64 1.0.2-2.el7_2
 libnfnetlink.x86_64 1.0.1-4.el7
 glibc.x86_64 2.17-325.el7_9
 glibc.i686 2.17-325.el7_9
 systemd.x86_64 219-78.el7_9.5

2.根据组织依赖下载包

第一步先下载要安装的rpm包
[root@x  conntrack-tools]# yumdownloader conntrack-tools 

第二步直接下载依赖的rpm包
[root@x conntrack-tools]# for i in `yum deplist conntrack-tools |grep provider |cut -d : -f 2  |uniq` ; do yumdownloader $i ; done

3.查看下载结果

[root@x conntrack-tools]# ls
bash-4.2.46-35.el7_9.x86_64.rpm         libnetfilter_conntrack-1.0.6-1.el7_3.x86_64.rpm
conntrack-tools-1.4.4-7.el7.x86_64.rpm  libnetfilter_cthelper-1.0.0-11.el7.x86_64.rpm
glibc-2.17-325.el7_9.i686.rpm           libnetfilter_cttimeout-1.0.0-7.el7.x86_64.rpm
glibc-2.17-325.el7_9.x86_64.rpm         libnetfilter_queue-1.0.2-2.el7_2.x86_64.rpm
libmnl-1.0.3-7.el7.x86_64.rpm           libnfnetlink-1.0.1-4.el7.x86_64.rpm
libnetfilter_conntrack-1.0.6-1.el7_3.i686.rpm  systemd-219-78.el7_9.5.x86_64.rpm

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# ls |wc -l
12

4.离线安装 rpm(未联网的环境也可以执行)

[root@x conntrack-tools]# rpm -Uvh --force --nodeps *.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:glibc-2.17-325.el7_9             warning: /etc/nsswitch.conf created as /etc/nsswitch.conf.rpmnew
################################# [  7%]
   2:libmnl-1.0.3-7.el7               ################################# [ 13%]
   3:libnfnetlink-1.0.1-4.el7         ################################# [ 20%]
   4:bash-4.2.46-35.el7_9             ################################# [ 27%]
   5:systemd-219-78.el7_9.5           ################################# [ 33%]
   6:libnetfilter_conntrack-1.0.6-1.el################################# [ 40%]
   7:libnetfilter_queue-1.0.2-2.el7_2 ################################# [ 47%]
   8:libnetfilter_cthelper-1.0.0-11.el################################# [ 53%]
   9:libnetfilter_cttimeout-1.0.0-7.el################################# [ 60%]
  10:glibc-2.17-325.el7_9             ################################# [ 67%]
  11:conntrack-tools-1.4.4-7.el7      ################################# [ 73%]
  12:libnetfilter_conntrack-1.0.6-1.el################################# [ 80%]
Cleaning up / removing...
  13:systemd-219-62.el7_6.7           ################################# [ 87%]
  14:bash-4.2.46-31.el7               ################################# [ 93%]
  15:glibc-2.17-260.el7_6.6           ################################# [100%]
    

5.测试

[root@iZbp1fy7y89tqjvmlp1dvhZ conntrack-tools]# conntrack -L
conntrack v1.4.4 (conntrack-tools): 0 flow entries have been shown.

[root@iZbp1fy7y89tqjvmlp1dvhZ]# conntrack -L|grep 55888

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值