一、本地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