将原有/etc/yum.repos.d/目录下的文件名全部改为(*.bak),如(红色标记)
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Base.repo.bak CentOS-CR.repo.bak CentOS-Debuginfo.repo.bak CentOS-fasttrack.repo.bak CentOS-Media.repo CentOS-Sources.repo.bak CentOS-Vault.repo.bak
[root@localhost yum.repos.d]# mv CentOS-Media.repo CentOS-Media.repo.bak
[root@localhost yum.repos.d]# yum clean all
将CentOS 7 镜像文件拷到 /media 目录下
上传CentOS7 ISO文件到/media/目录下,新建目录/media/cdrom,并将ISO文件挂载到/media/cdrom
[root@localhost media]# mkdir -p /media/cdrom
[root@localhost media]# ls
cdrom CentOS-7-x86_64-Everything-1503-01.iso
[root@localhost media]# mount -t auto /media/CentOS-7-x86_64-Everything-1503-01.iso /media/cdrom/
[root@localhost media]# ls /media/cdrom/
CentOS_BuildTag EFI EULA GPL images isolinux LiveOS Packages repodata RPM-GPG-KEY-CentOS-7 RPM-GPG-KEY-CentOS-Testing-7 TRANS.TBL
本地yum源配置
在/etc/yum.repos.d/路径下新建一个文件 CentOS-Media.repo,将以下内容复制到文件中即可;
# CentOS-Media.repo
#
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/cdrom
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#如果不需要gpgcheck,可让gpgcheck=0,然后注释掉最后一行即可。