实际工作中,我们经常会被要求,某台机器在没有网络的情况下安装部署一些工具,例如zabbix监控,nginx,mysql等等

国有单位很多业务是不能直接在线安装的,你想使用yum直接安装,因为不能联网,会报错误

Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"

One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only

这时候,甲方要求安装,但是不给提供网络,这对我们运维来说是一个调整,解决办法一般如下两种。

  1. 过河搭桥

    同一局域网如果有一台服务器可以上网,需要安装软件这台签好和这台可以上网机器网络是通的,我们可以在能上网这台机器行部署nginx正向代理

      解决方案:http代理上网

      使用squid配置http代理服务器,

      yum使用http代理,修改/etc/yum.conf

      最后一行添加:

proxy=http://代理IP:代理端口

  2. 乾坤大挪移

 安装一台和目标机器操作系统版本一样的系统

然后通过    yum install --downloadonly +软件名称 --downloaddir=指定rpm包存放路径
这样的就把用到所有安装包都下载好了,copy到U盘,通过rpm或者yum直接就可以安装了