准备工作:光盘挂载目录
rpm -q autofs || yum -y install autofs systemctl enable --now autofs
注:yum仓库指向的路径一定必须是repodata目录所在目录
#确认光盘已经挂载到/misc/cd目录下
[root@centos7 ~]#cd /misc/cd
[root@centos7 cd]#df /dev/sr0
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sr0 9961428 9961428 0 100% /misc/cd
#将默认的yum仓库的配置文件做备份
[root@centos7 cd]#cd /etc/yum.repos.d/
[root@centos7 yum.repos.d]#ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo epel.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-x86_64-kernel.repo epel-testing.repo
[root@centos7 yum.repos.d]#mkdir bak
[root@centos7 yum.repos.d]#mv *.repo bak/
[root@centos7 yum.repos.d]#ls
bak
#创建配置文件
[root@centos7 yum.repos.d]#vim base.repo
[root@centos7 yum.repos.d]#cat base.repo
[base]
name=CentOS
baseurl=file:///misc/cd
https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
https://repo.huaweicloud.com/centos/$releasever/os/$basearch/
gpgcheck=0
enabled=1
[extras]
name=Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/
https://repo.huaweicloud.com/centos/$releasever/extras/$basearch/
gpgcheck=0
enabled=1
[epel]
name=Epel
baseurl=https://mirrors.aliyun.com/epel/$releasever/$basearch/
https://mirrors.cloud.tencent.com/epel/$releasever/$basearch/
https://mirrors.huaweicloud.com/epel/$releasever/$basearch/
gpgcheck=0
enabled=1
#显示所有仓库
[root@centos7 yum.repos.d]#yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base:
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS 10,072
epel/7/x86_64 Epel 13,692
extras/7/x86_64 Extras 500
repolist: 24,264
|