創(chuàng)建掛載路徑
sudo mkdir /mnt/iso
掛載ISO鏡像到目錄
sudo mount -o loop CentOS-***.iso /mnt/iso
驗證掛載
df -h
修改文件名
進入/etc/yum.repos.d/路徑下因俐,把除CentOS-Media.repo文件外都加上old后綴
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.old
mv /etc/yum.repos.d/CentOS-CR.repo /etc/yum.repos.d/CentOS-CR.repo.old
mv /etc/yum.repos.d/CentOS-Debuginfo.repo /etc/yum.repos.d/CentOS-Debuginfo.repo.old
mv /etc/yum.repos.d/CentOS-fasttrack.repo /etc/yum.repos.d/CentOS-fasttrack.repo.old
mv /etc/yum.repos.d/CentOS-Sources.repo /etc/yum.repos.d/CentOS-Sources.repo.old
mv /etc/yum.repos.d/CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault.repo.old
編輯文件內(nèi)容
執(zhí)行命令vi /etc/yum.repos.d/CentOS-Media.repo莉测,把紅框內(nèi)內(nèi)容改成如下內(nèi)容:
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/iso
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
更新yum源
yum clean all
yum makecache
驗證
使用yum安裝:yum install -y perl-DBD-MySQL惊楼,命令正常執(zhí)行,證明配置成功