由于客户环境网络有限制,不能直接在线yum镜像来下载相关的依赖,所以只能配置离线Yum源并进行离线安装。
一、准备离线Yum源
获取CentOS 7的官方或第三方镜像,如DVD ISO或网络安装源的完整副本。这些通常包含大量的软件包供离线环境使用。可以从以下来源获取:
第三方镜像站点:阿里云地址: link
根据服务器的32/64位,下载ios结尾的
二、挂载ISO镜像或解压本地镜像
下载好后,上传到服务器某个目录,不用解压
如我自己的
mkdir -p /mnt/cdrom
挂载
sudo mount -o loop /mnt/CentOS-7-x86_64-DVD-1708.iso /mnt/cdrom
备份之前的镜像配置
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
修改
sudo vi /etc/yum.repos.d/CentOS-Base.repo
# CentOS-+1-4.5/6183<4=4=4=Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - Local Repository
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
#released updates
[updates]
[updates]
name=CentOS-$releasever - Updates - Local Repository
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - Local Repository
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
#additional packages that extend functionality of existing packages
[centosplus]
[centosplus]
name=CentOS-$releasever - Plus - Local Repository
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
#contrib - packages by Centos Users
[contrib]
[contrib]
name=CentOS-$releasever - Contrib - Local Repository
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
然后执行 清理缓存并重新生成YUM缓存
1、yum clean all
2、yum makecache
至此离线镜像源安装配置完成