使用yumdownloader命令离线安装rpm服务包

简介: 使用yumdownloader命令离线安装rpm服务包

公司场景需求:离线服务器上安装一个nginx服务

系统版本:CentOS 7.6


方法一:

使用tar包,二进制安装 略

方法二:

rpm方式


安装rpm包时,应该大家都遇到过缺少依赖包的问题,一个一个安装依赖文件,让人头疼。

这里给大家介绍一种很方便的安装方法

使用yumdownloader命令离线安装 nginx rpm服务包


1.首先找一个可以连接外网的服务器

可以ping通百度域名,确定可以上外网
[root@243-ceshi /]# ping www.baidu.com
PING www.baidu.com 
icmp_seq=1 ttl=53 time=23.5 ms
icmp_seq=2 ttl=53 time=22.8 ms
icmp_seq=3 ttl=53 time=27.3 ms

2.安装插件

[root@localhost ~]# yum install yum-utils

3.创建一个存放rpm包的目录

[root@localhost ~]# mkdir /rpm

4.下载nginx rpm相关文件

[root@localhost rpm]# yumdownloader --resolve --destdir=/rpm  nginx

5.查看rpm目录下的文件

[root@243-ceshi rpm]# ls
centos-indexhtml-7-9.el7.centos.noarch.rpm  nginx-mod-http-image-filter-1.16.1-3.el7.x86_64.rpm
gd-2.0.35-27.el7_9.x86_64.rpm               nginx-mod-http-perl-1.16.1-3.el7.x86_64.rpm
gperftools-libs-2.6.1-1.el7.x86_64.rpm      nginx-mod-http-xslt-filter-1.16.1-3.el7.x86_64.rpm
libXpm-3.5.12-1.el7.x86_64.rpm              nginx-mod-mail-1.16.1-3.el7.x86_64.rpm
nginx-1.16.1-3.el7.x86_64.rpm               nginx-mod-stream-1.16.1-3.el7.x86_64.rpm
nginx-all-modules-1.16.1-3.el7.noarch.rpm   openssl11-libs-1.1.1g-2.el7.x86_64.rpm
nginx-filesystem-1.16.1-3.el7.noarch.rpm

nginx最新版本的相关依赖文件全在都rpm目录下了

6.把rpm目录下文件移到内网服务器的/rpm目录下

[root@243-ceshi /]# scp -r /rpm root@192.168.1.168:/rpm
root@192.168.1.168's password:
centos-indexhtml-7-9.el7.centos.noarch.rpm                                                100%   92KB  19.7MB/s   00:00
gd-2.0.35-27.el7_9.x86_64.rpm                                                             100%  146KB  22.7MB/s   00:00
gperftools-libs-2.6.1-1.el7.x86_64.rpm                                                    100%  272KB  26.2MB/s   00:00
libXpm-3.5.12-1.el7.x86_64.rpm                                                            100%   55KB  17.6MB/s   00:00
nginx-1.16.1-3.el7.x86_64.rpm                                                             100%  563KB  31.4MB/s   00:00
nginx-all-modules-1.16.1-3.el7.noarch.rpm                                                 100%   20KB   8.2MB/s   00:00
nginx-filesystem-1.16.1-3.el7.noarch.rpm                                                  100%   21KB   9.0MB/s   00:00
nginx-mod-http-image-filter-1.16.1-3.el7.x86_64.rpm                                       100%   30KB  12.0MB/s   00:00
nginx-mod-http-perl-1.16.1-3.el7.x86_64.rpm                                               100%   39KB  14.3MB/s   00:00
nginx-mod-http-xslt-filter-1.16.1-3.el7.x86_64.rpm                                        100%   29KB  11.9MB/s   00:00
nginx-mod-mail-1.16.1-3.el7.x86_64.rpm                                                    100%   57KB  16.6MB/s   00:00
nginx-mod-stream-1.16.1-3.el7.x86_64.rpm                                                  100%   85KB  18.1MB/s   00:00
openssl11-libs-1.1.1g-2.el7.x86_64.rpm                                                    100% 1485KB  40.6MB/s   00:00

7.进入离线服务器安装

[root@localhost /]# cd /rpm
[root@localhost rpm]# rpm -ivh * --nodeps --force
警告:nginx-1.16.1-3.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
准备中...                          ################################# [100%]
正在升级/安装...
   1:openssl11-libs-1:1.1.1g-2.el7    ################################# [  8%]
   2:nginx-filesystem-1:1.16.1-3.el7  ################################# [ 15%]
   3:libXpm-3.5.12-1.el7              ################################# [ 23%]
   4:gd-2.0.35-27.el7_9               ################################# [ 31%]
   5:gperftools-libs-2.6.1-1.el7      ################################# [ 38%]
   6:centos-indexhtml-7-9.el7.centos  ################################# [ 46%]
   7:nginx-mod-http-image-filter-1:1.1################################# [ 54%]
   8:nginx-mod-http-perl-1:1.16.1-3.el################################# [ 62%]
   9:nginx-mod-http-xslt-filter-1:1.16################################# [ 69%]
  10:nginx-mod-mail-1:1.16.1-3.el7    ################################# [ 77%]
  11:nginx-all-modules-1:1.16.1-3.el7 ################################# [ 85%]
  12:nginx-1:1.16.1-3.el7             ################################# [ 92%]
  13:nginx-mod-stream-1:1.16.1-3.el7  ################################# [100%]

8.启动nginx服务

[root@localhost rpm]# systemctl start nginx
[root@localhost rpm]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
   Active: active (running) since 四 2021-01-21 15:24:46 CST; 5s ago
  Process: 127308 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
  Process: 127303 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
  Process: 127300 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
 Main PID: 127318 (nginx)
    Tasks: 7
   Memory: 7.8M
   CGroup: /system.slice/nginx.service
           ├─127318 nginx: master process /usr/sbin/nginx
           ├─127319 nginx: worker process
           ├─127320 nginx: worker process
           ├─127322 nginx: worker process
           ├─127323 nginx: worker process
           ├─127324 nginx: worker process
           └─127325 nginx: worker process
1月 21 15:24:46 vrgv systemd[1]: Starting The nginx HTTP and reverse proxy server...
1月 21 15:24:46 vrgv nginx[127303]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
1月 21 15:24:46 vrgv nginx[127303]: nginx: configuration file /etc/nginx/nginx.conf test is successful
1月 21 15:24:46 vrgv systemd[1]: Started The nginx HTTP and reverse proxy server.

离线安装nginx服务及依赖文件完成

相关文章
|
2月前
|
Ubuntu Unix Linux
在Ubuntu安装RPM文件
Ubuntu使用`apt`和`alien`工具安装软件。`deb`是Ubuntu的标准包格式,但通过`alien`可转换及安装`RPM`包。首先确保启用`Universe`源,然后安装`alien`。转换RPM包为DEB包,运行`sudo alien package_name.rpm`,接着用`sudo apt install package_name.deb`安装。直接安装RPM包可使用`sudo alien -i package_name.rpm`,但这种方法不推荐,可能导致依赖性冲突和系统不稳定。
61 10
|
11月前
|
存储 Linux
如何使用`yum`命令安装RPM软件包?
如何使用`yum`命令安装RPM软件包?
612 0
|
SQL 存储 分布式计算
安装部署--rpm 包本地 yum 源制作 | 学习笔记
快速学习 安装部署--rpm 包本地 yum 源制作
397 0
安装部署--rpm 包本地 yum 源制作 | 学习笔记
|
域名解析 Ubuntu Linux
安装软件包
本文以阿里云软件源中的Apache服务器为例,为大家讲解如何在不同Linux发行版上安装软件包。
1311 0
安装软件包
|
Ubuntu 前端开发 数据库