Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > yum无法安装epel-release

如何解决yum无法安装epel-release的问题

作者:花不完根本花不完

这篇文章主要介绍了如何解决yum无法安装epel-release的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

yum无法安装epel-release

在学习Hadoop的过程中准备环境时需要安装epel-release

在安装之前ping了一下www.baidu.com 发现能ping通,然后就去安装了,然后就发现问题了

去网上搜了一下然后感觉应该是镜像源的问题,

尝试了第一种方法

修改了/etc/yum.repos.d目录下的CentOS-Base.rep文件,将文件中的原有内容改为

# CentOS-Base.repo
    #
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client.  You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the 
    # remarked out baseurl= line instead.
    #
    #
     
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
     
    #released updates 
    [updates]
    name=CentOS-$releasever - Updates
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
     
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
    #$baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
     
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
    baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

然后执行

sudo yum clean all
sudo yum makecache

然后我的这两个命令就都加载失败了,我觉得就是这个不行

但是我把后续的解决方法放到下面,有人成功了可以继续往下试试

再执行

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

然后查看一下CentOS-Base.repo`中的地址是否改成阿里云的了

cat CentOS-Base.repo`

再此尝试导入wget命令 好的成功了

第二种方法(我就是用这种方法解决的)

#建议是备份一下

rm -rf /etc/yum.repos.d mkdir /etc/yum.repos.d

wget http://mirrors.aliyun.com/repo/Centos-7.repo cp Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo

#安装 rpm -ivh wget-1.14-15.el7_4.1.x86_64.rpm

yum clean all yum makecache

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文