CentOS7搭建本地yum源

近几天新开了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后正常。

下面是完整步骤:

  1. 创建文件夹
mkdir /media/cdrom
  1. 在VMware中添加光盘,设置开机启动
    在这里插入图片描述
  2. 挂载ISO
mount /dev/cdrom /media/cdrom
  1. 修改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
  1. 关闭网络,检验本地yum源
yum clean all				#清除缓存
yum makecache				#建立缓存
yum -y install httpd		#安装httpd
  1. 如果还是和我一样的报错,检查是否有安装其他的yum源。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值