ASCII码 ASCII码

yum安装 一直出现There are no enabled repositories in “/etc/yum.repos.d“, “/etc/yum/repos.d“, 的解决办法

发布于:2022-06-08 09:19:06  栏目:技术文档

镜像下载、域名解析、时间同步请点击 阿里云开源镜像站

在CentOS中使用yum命令出现报错:

今天想给linux装个git 管理代码

执行命令:

  1. 1 yum -y install git

然后出现了这么一句

  1. error:There are no enabled repositories in "/etc/yum.repos.d", "/etc/yum/repos.d

然后就各种找问题,各种查,各种试

比如(别复制这段,这段是错的,解决不了)

  1. vi /etc/yum.repos.dopenEuler_x86_64.repo
  1. #generic-repos is licensed under the Mulan PSL v2.
  2. #You can use this software according to the terms and conditions of the Mulan PSL v2.
  3. #You may obtain a copy of Mulan PSL v2 at:
  4. # http://license.coscl.org.cn/MulanPSL2
  5. #THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
  6. #IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
  7. #PURPOSE.
  8. #See the Mulan PSL v2 for more details.
  9. [OS]
  10. name=OS
  11. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/
  12. enabled=1
  13. gpgcheck=1
  14. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
  15. [everything]
  16. name=everything
  17. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/
  18. enabled=1
  19. gpgcheck=1
  20. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/everything/$basearch/RPM-GPG-KEY-openEuler
  21. [EPOL]
  22. name=EPOL
  23. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/$basearch/
  24. enabled=1
  25. gpgcheck=1
  26. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler
  27. [debuginfo]
  28. name=debuginfo
  29. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/
  30. enabled=1
  31. gpgcheck=1
  32. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/debuginfo/$basearch/RPM-GPG-KEY-openEuler
  33. [source]
  34. name=source
  35. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/source/
  36. enabled=1
  37. gpgcheck=1
  38. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/source/RPM-GPG-KEY-openEuler
  39. [update]
  40. name=update
  41. baseurl=http://repo.openeuler.org/openEuler-20.03-LTS/update/$basearch/
  42. enabled=0
  43. gpgcheck=1
  44. gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/$basearch/RPM-GPG-KEY-openEuler

然后发现yum源根本没有

所以,首先先安装yum源

解决办法

安装yum源

1.进入目录

  1. cd /etc/yum.repos.d

2.查看并删除/etc/yum.repos.d目录下所有的配置文件

  1. 1 ll //查看当前目录的所有文件
  2. 2 rm -rf ./* //删除当前的所有文件

然后会出现(这图是截图人家的,我当时没截图)

file

3.下载centos8的镜像源

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

然后会看到这样

file

接着

  1. ls //查看文件
  2. yum -y clean all //清除所有文件
  3. yum -y makecache //建立缓存

然后你可能会发现,建立缓存失败

提示是这样

  1. Error: Failed to download metadata for repo 'base'

解决办法

切换源(任选一个命令,我这选的是1 看着来吧)

命令1:

  1. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

命令2:

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

然后再重新建立缓存

  1. yum makecache

如果还不成功就运行这个

  1. yum clear all

然后建立缓存

  1. yum makecache

然后就可以了!反正我到这一步后就可以yum -y install git 了

file

最后

yum取的源可能是CentOS-Base.repo里面的配置,也可能取的是单个配置文件里面的,比如AppStream的源可能取CentOS-AppStream.repo里面的配置,也可能取CentOS-Base.repo的配置,这两者可能会冲突,也可能不会冲突,不冲突报错可不理,若是报错,建议先重命名备份CentOS-AppStream.repo文件。

本文转自:https://blog.csdn.net/weixin_56483756/article/details/124185212

相关推荐
阅读 +