一、本地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
二、配置CentOS YUM源
1、备份源文件
cd /etc/yum.repos.d/
mkdir bak
mv *.repo bak/
2、下载CentOS-Base.repo 到/etc/yum.repos.d/
cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/ https://mirrors.aliyun.com/repo/Centos-8.repo
mv Centos-8.repo redhat.repo
3、清理YUM缓存,重建YUM仓库
yum clean all
yum makecache
yum repolist