Centos7部署本地yum
1、VMware虛擬化平臺,在vCenter將本地儲存的Centos ISO掛載到到虛擬伺服器上。
2、建立 目錄/mnt/cdrom
[[email protected] ~]# mkdir /mnt/cdrom
3、將映象掛載到目錄
[[email protected] ~]# mount -o ro /dev/cdrom /mnt/cdrom/
4、備份之前的CentOS-Base.repo Yum源
[[email protected] ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[[email protected] ~]# cd /etc/yum.repos.d/
5、修改CentOS-Media.repo
[[email protected] 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
[[email protected] yum.repos.d]# yum clean all
[[email protected] 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