内网环境centos7 yum离线安装软件包

场景

在日常的软件部署中,不知道小伙伴们会不会遇到如下情况:

客户的服务器处于内网环境,没有与互联网环联通。

所以不能使用yum在线软件源安装,那么能不能先将所需的软件下载下来,到时候在内网环境下再离线安装呢?答案是肯定的。关于这个功能yum需要一个插件(yum-plugin-downloadonly)的支持。

安装插件

yum install -y yum-plugin-downloadonly

yum离线下载软件包

下载的时候需要使用"- -downloadonly"参数,用于指定软件包下载后存储路径,该参数不会安装软件。
下面以docker软件包为例:

yum install -y --downloadonly --downloaddir=. docker

内网环境centos7 yum离线安装软件包_第1张图片
下载完成后:

[root@localhost docker]# ls
atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm
audit-2.8.4-4.el7.x86_64.rpm
audit-libs-2.8.4-4.el7.x86_64.rpm
audit-libs-python-2.8.4-4.el7.x86_64.rpm
checkpolicy-2.5-8.el7.x86_64.rpm
containers-common-0.1.31-8.gitb0b750d.el7.centos.x86_64.rpm
container-selinux-2.74-1.el7.noarch.rpm
container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm
docker-1.13.1-91.git07f3374.el7.centos.x86_64.rpm
docker-client-1.13.1-91.git07f3374.el7.centos.x86_64.rpm
docker-common-1.13.1-91.git07f3374.el7.centos.x86_64.rpm
libcgroup-0.41-20.el7.x86_64.rpm
libselinux-2.5-14.1.el7.x86_64.rpm
libselinux-python-2.5-14.1.el7.x86_64.rpm
libselinux-utils-2.5-14.1.el7.x86_64.rpm
libsemanage-2.5-14.el7.x86_64.rpm
libsemanage-python-2.5-14.el7.x86_64.rpm
libsepol-2.5-10.el7.x86_64.rpm
libyaml-0.1.4-11.el7_0.x86_64.rpm
oci-register-machine-0-6.git2b44233.el7.x86_64.rpm
oci-systemd-hook-0.1.18-3.git8787307.el7_6.x86_64.rpm
oci-umount-2.3.4-2.git87f9237.el7.x86_64.rpm
policycoreutils-2.5-29.el7_6.1.x86_64.rpm
policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm
python-backports-1.0-8.el7.x86_64.rpm
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
python-ipaddress-1.0.16-2.el7.noarch.rpm
python-IPy-0.75-6.el7.noarch.rpm
python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm
python-setuptools-0.9.8-7.el7.noarch.rpm
PyYAML-3.10-11.el7.x86_64.rpm
selinux-policy-3.13.1-229.el7_6.9.noarch.rpm
selinux-policy-targeted-3.13.1-229.el7_6.9.noarch.rpm
setools-libs-3.3.8-4.el7.x86_64.rpm
subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64.rpm
yajl-2.0.4-4.el7.x86_64.rpm

yum离线安装软件包

下载好后的软件包,使用yum localinstall 即可以离线安装。

[root@localhost docker]# yum localinstall -y --nogpgcheck \
atomic-registries-1.22.1-26.gitb507039.el7.centos.x86_64.rpm \
audit-2.8.4-4.el7.x86_64.rpm \
audit-libs-2.8.4-4.el7.x86_64.rpm \
audit-libs-python-2.8.4-4.el7.x86_64.rpm \
checkpolicy-2.5-8.el7.x86_64.rpm \
containers-common-0.1.31-8.gitb0b750d.el7.centos.x86_64.rpm \
container-selinux-2.74-1.el7.noarch.rpm \
container-storage-setup-0.11.0-2.git5eaf76c.el7.noarch.rpm \
docker-1.13.1-91.git07f3374.el7.centos.x86_64.rpm \
docker-client-1.13.1-91.git07f3374.el7.centos.x86_64.rpm \
docker-common-1.13.1-91.git07f3374.el7.centos.x86_64.rpm \
libcgroup-0.41-20.el7.x86_64.rpm \
libselinux-2.5-14.1.el7.x86_64.rpm \
libselinux-python-2.5-14.1.el7.x86_64.rpm \
libselinux-utils-2.5-14.1.el7.x86_64.rpm \
libsemanage-2.5-14.el7.x86_64.rpm \
libsemanage-python-2.5-14.el7.x86_64.rpm \
libsepol-2.5-10.el7.x86_64.rpm \
libyaml-0.1.4-11.el7_0.x86_64.rpm \
oci-register-machine-0-6.git2b44233.el7.x86_64.rpm \
oci-systemd-hook-0.1.18-3.git8787307.el7_6.x86_64.rpm \
oci-umount-2.3.4-2.git87f9237.el7.x86_64.rpm \
policycoreutils-2.5-29.el7_6.1.x86_64.rpm \
policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm \
python-backports-1.0-8.el7.x86_64.rpm \
python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm \
python-ipaddress-1.0.16-2.el7.noarch.rpm \
python-IPy-0.75-6.el7.noarch.rpm \
python-pytoml-0.1.14-1.git7dea353.el7.noarch.rpm \
python-setuptools-0.9.8-7.el7.noarch.rpm \
PyYAML-3.10-11.el7.x86_64.rpm \
selinux-policy-3.13.1-229.el7_6.9.noarch.rpm \
selinux-policy-targeted-3.13.1-229.el7_6.9.noarch.rpm \
setools-libs-3.3.8-4.el7.x86_64.rpm \
subscription-manager-rhsm-certificates-1.21.10-3.el7.centos.x86_64.rpm \
yajl-2.0.4-4.el7.x86_64.rpm

注意事项:

  1. yum localinstall 后面要指定安装所需的全部rpm包
  2. 除了yum localinstall命令以外,还可以使用rpm -ivh命令安装rpm包。
    内网环境centos7 yum离线安装软件包_第2张图片

验证安装结果

[root@localhost docker]# systemctl  start docker 
[root@localhost docker]# docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

docker 安装成功

参考资料

https://www.yanning.wang/archives/664.html

你可能感兴趣的:(linux,命令)