内网环境yum安装依赖包问题

使用yum安装软件时,可以自动处理依赖关系,但在内网环境下,服务器无法访问互联网,如果依赖包较多,若网上一个一个去找,着实费劲!这时就可以用到这篇文章中的方法来解决,提高效率。

其实说白了就是,先找一台能访问互联网,且相同环境的Linux,再通过yum下载某个软件及其所需的依赖包,再拷贝到内网服务器上yum安装。这里以centos7为例。

更换阿里云yum源

cp -r /etc/yum.repos.d/ /etc/yum.repos.d.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y epel-release
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all
yum makecache
yum repolist

下载依赖包到本地

mkdir -p /root/rpm
yum install --downloadonly --downloaddir=/root/rpm docker
yum install --hlep
  --downloadonly        don't update, just download
  --downloaddir=DLDIR   specifies an alternate directory to store packages

报错

container-selinux-2.119.2-1.91 FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/Packages/container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyuncs.com; Unknown error"
Trying other mirror.
policycoreutils-2.5-34.el7.x86 FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/policycoreutils-2.5-34.el7.x86_64.rpm: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/policycoreutils-2.5-34.el7.x86_64.rpm: (28, 'Connection timed out after 30002 milliseconds')
Trying other mirror.
policycoreutils-2.5-34.el7.x86 FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/Packages/policycoreutils-2.5-34.el7.x86_64.rpm: [Errno 14] curl#6 - "Could not resolve host: mirrors.aliyuncs.com; Name or service not known"
Trying other mirror.

Error downloading packages:
  2:container-selinux-2.119.2-1.911c772.el7_8.noarch: [Errno 256] No more mirrors to try.
  python-pytoml-0.1.14-1.git7dea353.el7.noarch: [Errno 256] No more mirrors to try.
  policycoreutils-2.5-34.el7.x86_64: [Errno 256] No more mirrors to try.
  policycoreutils-python-2.5-34.el7.x86_64: [Errno 256] No more mirrors to try.
  1:oci-register-machine-0-6.git2b44233.el7.x86_64: [Errno 256] No more mirrors to try.

单独下载rpm,缺啥补啥,列几个rpm下载网站:
centos.pkgs.org 推荐这个网站,比较全,有rpm的详细说明,包括rpm的主站、所需依赖、更新日志等,注意下载对应版本的rpm
rpm.pbone.net 这个网站也很全,但是访问很慢,而且网站设计不友好,查找不如第一个网站方便
mirror.centos.org centos站点
mirrors.aliyun.com 阿里云的也挂在这里,但不用去找了,也找不到,因为我们yum源就是阿里云

打包拷贝,yum安装

打包/root/rpm,记得把报错提示中缺少的rpm也打包进去

tar -zcvf rpm.tar.gz /root/rpm/

拷贝到目标服务器,解压,yum安装

tar -zxvf rpm.tar.gz
cd ~/rpm
yum localinstall -y *.rpm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值