300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > linux centos7 报错: “Repository base is listed more than once in the

linux centos7 报错: “Repository base is listed more than once in the

时间:2018-10-18 21:01:14

相关推荐

linux centos7 报错: “Repository base is listed more than once in the

目录

报错描述

解决方案

总结

报错描述

我的 CentOS 7 的更新源使用的是直接从 163 镜像站上下载的更新源文件.

今天在使用yum makecache命令从更新服务器上把软件包的信息下载到本地缓存起来时遇到了如下报错:

Repository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configuration

报错截图如下:

图 1

而且在我使用yum install htop命令安装htop的时候, 还提示:

没有可用软件包 htop。

错误:无须任何处理

但是, 正常情况下 CentOS 7 的源里面应该是有htop这个软件包的, 可以直接使用yum install htop成功安装(我之前安装过).

上述问题的相关截图如下:

图 2

解决方案

分析上面的报错, 主要还是软件源文件出了问题, 于是我们先进入软件源配置文件所在的目录下:

cd /etc/yum.repos.d/

ls查看一下, 回显如下:

[root@localhost yum.repos.d]# lsCentOS7-Base-163.repo CentOS-CR.repo CentOS-Media.repoCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Sources.repoCentOS-Base.repo.backup CentOS-fasttrack.repo CentOS-Vault.repo[root@localhost yum.repos.d]#

从对报错内容的分析来看, 应该是软件源有重复(“listed more than once”), 所以这里我们尝试删除一些上面的软件源配置文件.

在删除之前, 先对/etc/yum.repos.d/目录下的文件做一个整体的备份, 以便于尝试失败后的还原, 操作过程如下:

/etc/yum.repos.d/目录下的文件整体压缩成一个.zip文件:

zip centos7-repo.zip /etc/yum.repos.d/*

然后执行删除操作:

rm -rf CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo

之后把CentOS7-Base-163.repo中的内容复制进CentOS-Base.repo:

cp -p CentOS7-Base-163.repo CentOS-Base.repo

最后删除CentOS7-Base-163.repo:

rm -rf CentOS7-Base-163.repo

之后运行如下命令重建缓存, 没有再出现"Repository base is listed more than once in the configuration"的报错:

yum clean allyum makecache

但是, 在我尝试使用yum命令安装软件时, 仍然遇到了"没有可用软件包 XXX"的报错, 如下:

[root@localhost yum.repos.d]# yum install htop已加载插件:fastestmirror, langpacksLoading mirror speeds from cached hostfile没有可用软件包 htop。错误:无须任何处理

“没有可用软件包"说明在 YUM 源中没有对应的软件包(163 的源本身应该是没有问题的, 这是一个大家都常使用的 Linux 方面的国内软件源).

其实, 在 CentOS 和 RHEL 等操作系统中, 常使用的软件源不仅有 YUM, 还有 EPEL. EPEL 英文全称为:“Extra Packages for EnterpriseLinux”. 直译为中文就是"用于企业 Linux 的额外软件包”. EPEL 是 Fedora 的一个项目, 有关该项目的官方说明可以在下面的链接中找到:

EPEL - Fedora Project Wiki

这里我摘录一段 Fedora 对 EPEL 项目的说明:

企业版 Linux 附加软件包(以下简称 EPEL)是一个 Fedora 特别兴趣小组,用以创建、维护以及管理针对企业版 Linux 的一个高质量附加软件包集,面向的对象包括但不限于 红帽企业版 Linux (RHEL)、 CentOS、Scientific Linux (SL)、Oracle Linux (OL) 。

EPEL 的软件包通常不会与企业版 Linux 官方源中的软件包发生冲突,或者互相替换文件。EPEL 项目与 Fedora 基本一致,包含完整的构建系统、升级管理器、镜像管理器等等。

– 来自:EPEL/zh-cn - Fedora Project Wiki

在 CentOS 7 中安装 EPEL 源的命令如下:

yum install -y epel-release

安装完成后, 在/etc/yum.repos.d目录下会多出来下面两个文件, 这两个文件就是 EPEL 源的配置文件:

epel.repoepel-testing.repo

查看epel.repo文件中的内容可以发现其中软件源的地址指向的是/,epel-testing.repo这个文件中的软件源的地址也是指向的是/. 为了加快软件安装速度, 我们可以将其更改为国内的 EPEL 源, 操作步骤如下:

进入/etc/yum.repos.d目录, 下载阿里云 EPEL 源:

wget /repo/epel-7.repo

备份 Fedora 官方提供的 EPEL 源配置文件:

cp -p epel.repo epel.repo.bakcp -p epel-testing.repo epel-testing.repo.bak

删除epel-testing.repo:

rm -rf epel-testing.repo

epel-7.repo中的内容覆盖写入到原来的epel.repo文件中:

cp -p epel-7.repo epel.repo

删除epel-7.repo文件:

rm -rf epel-7.repo

重新生成缓存:

yum clean allyum makecache

之后可以正常安装软件.

总结

遇到"Repository base is listed more than once in the configuration"的问题要考虑系统中是否存在重复的软件源, 遇到"没有可用软件包 XXX"的问题首先要确认要安装的软件包名称是否写对了, 例如安装 pip 的命令不是yum install pip, 而是yum install python-pip, 在此之后如果问题仍然存在就需要考虑当前系统中是否正确配置了 YUM 和 EPEL 两个软件源.

linux centos7 报错: “Repository base is listed more than once in the configuration“和“没有可用软件包 xxx“ 解决方法

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。