1、VMware虚拟化平台,在vCenter将本地存储的Centos ISO挂载到到虚拟服务器上。
2、创建 目录/mnt/cdrom
[root@lc001 ~]# mkdir /mnt/cdrom
3、将镜像挂载到目录
[root@lc001 ~]# mount -o ro /dev/cdrom /mnt/cdrom/
4、备份之前的CentOS-Base.repo Yum源
[root@lc001 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@lc001 ~]# cd /etc/yum.repos.d/
5、修改CentOS-Media.repo
[root@lc001 yum.repos.d]# vi CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom #增加这一行
#baseurl=file:///media/CentOS/ #将这一行注释
# file:///media/cdrom/ #将这一行注释
# file:///media/cdrecorder/ #将这一行注释
gpgcheck=1
enabled=1 #将0改成1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
6、执行yum clean all和yum makecache
[root@lc001 yum.repos.d]# yum clean all
[root@lc001 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
c7-media | 3.6 kB 00:00:00
(1/4): c7-media/group_gz | 166 kB 00:00:00
(2/4): c7-media/primary_db | 5.9 MB 00:00:00
(3/4): c7-media/filelists_db | 6.9 MB 00:00:00
(4/4): c7-media/other_db | 2.5 MB 00:00:00
Metadata Cache Created