1.CentOS下载镜像
官网地址:https://www.centos.org/download/ 国内镜像地址:https://mirrors.aliyun.com/centos/7/isos/x86_64/
推荐使用国内镜像
2.创建ISO存放目录以及挂载目录
mkdir /mnt/iso /mnt/cdrom
3.上传ISO镜像文件至/mnt/iso
4.挂载ISO镜像到挂载目录
mount -o loop /mnt/iso/*.iso /mnt/cdrom
5. 检查挂载是否成功
df -h
6.备份/etc/yum.repos.d文件至备份文件夹
7.创建repo文件并存放
touch local.repo mv ./local.repo /etc/yum.repos.d
8.写入信息至local.repo
[local] name=local #挂载地址:/mnt/cdrom baseurl=file:///mnt/cdrom enabled=1 gpgcheck=0 #cd /mnt/cdrom/可以看到KEY gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-CentOS-7
9.测试yum安装
yum clean all yum install ntp
10.取消挂载
umount /mnt/cdrom