一、本地YUM源
1、#备份原文件
cd /etc/yum.repos.d/
mkdir bak
mv .repo bak/
2、#挂载镜像
mount -t iso9660 /dev/cdrom /mnt/
#开机挂载
echo "mount -o loop -t iso9660 /dev/cdrom /mnt/" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
/etc/rc.d/rc.local
3、#编辑YUM源仓库文件
vim /etc/yum.repos.d/local.repo
#新增
[localREPO]
name=localhost8
baseurl=file:///mnt/cdrom/BaseOS
enable=1
gpgcheck=0
[localREPO_APP]
name=localhost8_app
baseurl=file:///mnt/cdrom/AppStream
enable=1
gpgcheck=0
4、#清YUM缓存,重建YUM数据库
yum clean all
yum makecache
yum repolist
二、配置阿里云YUM源
1、#备份原文件
cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak/
2、#下载阿里云YUM源文件
cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/redhat.repo http://mirrors.aliyun.com/repo/Centos-8.repo
3、#清YUM缓存,重建YUM数据库
yum clean all
yum makecache
yum repolist
原文:https://blog.51cto.com/13594560/2485859