centos7.X设置本地YUM源

下面以centos7.5为例子

1、首先把centos7.5的iso镜像文件拷贝/home下

iso镜像可到:

http://mirrors.aliyun.com/centos-vault/7.5.1804/isos/x86_64/

下载:CentOS-7-x86_64-DVD-1804.iso

1.1.创建以下目录:
mkdir /home/yum-iso mkdir /home/yum/
1.2.把iso系统解压到指定路径下:
mount -o loop CentOS-7-x86_64-DVD-1804.iso /home/yum-iso
1.3.把iso解压到yum-iso文件拷贝到yum路径下
scp -r /home/yum-iso/ /home/yum
1.4.查看拷贝情况
ll yum

2、进入yum.repos.d文件路径下

cd /etc/yum.repos.d/
2.1.用tar打包备份文件
tar -zcvf repo-bk.tar.gz CentOS-*
2.2.rm -f 删掉不必要的文件
rm -f CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Sources.repo CentOS-Vault.repo

3.配置本地CentOS-Media.repo

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:///home/yum/yum-iso/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
3.1.检测安装软件是否成功
yum clean all yum makecache

yum -y install ntp

你可能感兴趣的:(centos7.X设置本地YUM源)