近几天新开了CentOS7虚拟机,想来复习一下,在搭建本地yum源的时候遇到了一点小问题,报错如下,
[root@localhost yum.repos.d]# yum install httpd
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
Cannot retrieve metalink for repository: epel/x86_64. Please verify its path and try again
我刚开始以为是CentOS7.6的特性,做了限制,一通检查发现是我只备份删除了base源, 没有删除epel源,关闭网络后yum还是会从epel安装,与网络地址不通就会有这个报错,根本不会继续用本地源来安装软件。删除epel.repo后正常。
下面是完整步骤:
- 创建文件夹
mkdir /media/cdrom
- 在VMware中添加光盘,设置开机启动
- 挂载ISO
mount /dev/cdrom /media/cdrom
- 修改repo文件
cd /etc/yum.repos.d #移动到yum目录
mv CentOS-Base.repo CentOS-Base.repo.bak #备份repo文件
vim CentOS-Media.repo #修改本地光盘仓库的配置文件,默认是关闭的,将enabled=0改动就行
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///media/cdrom/
file:///mnt/cdrom/
file:///media/cdrecorder/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- 关闭网络,检验本地yum源
yum clean all #清除缓存
yum makecache #建立缓存
yum -y install httpd #安装httpd
- 如果还是和我一样的报错,检查是否有安装其他的yum源。