centos 7.1 - 错误库

centos 7.1 - error repository

您好,我已经下载了CENTOS 7的最小版本url link download ISO centos 7.x

一切正常...PING 和网络正常。例如,我 ping 到外部主机。

但是当我数字时:

[root@localhost ~]# yum update
Loaded plugins: fastestmirror


 One of the configured repositories failed (Unknown),
 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. Disable the repository, 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>

     4. 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 find a valid baseurl for repo: base/7/x86_64

为什么?

This is another command:


root@localhost ~]# yum repolist all
Loaded plugins: fastestmirror
repo id                           repo name                           status
C7.0.1406-base/x86_64             CentOS-7.0.1406 - Base              disabled
C7.0.1406-centosplus/x86_64       CentOS-7.0.1406 - CentOSPlus        disabled
C7.0.1406-extras/x86_64           CentOS-7.0.1406 - Extras            disabled
C7.0.1406-fasttrack/x86_64        CentOS-7.0.1406 - CentOSPlus        disabled
C7.0.1406-updates/x86_64          CentOS-7.0.1406 - Updates           disabled
base/7/x86_64                     CentOS-7 - Base                     enabled: 0
base-debuginfo/x86_64             CentOS-7 - Debuginfo                disabled
base-source/7                     CentOS-7 - Base Sources             disabled
centosplus/7/x86_64               CentOS-7 - Plus                     disabled
centosplus-source/7               CentOS-7 - Plus Sources             disabled
cr/7/x86_64                       CentOS-7 - cr                       disabled
extras/7/x86_64                   CentOS-7 - Extras                   enabled: 0
extras-source/7                   CentOS-7 - Extras Sources           disabled
fasttrack/7/x86_64                CentOS-7 - fasttrack                disabled
updates/7/x86_64                  CentOS-7 - Updates                  enabled: 0
updates-source/7                  CentOS-7 - Updates Sources          disabled
repolist: 0
[root@localhost ~]#

文件内容/etc/yum.repos.d/CentOS-Base.repo

[root@localhost ~]# cat /etc/yum.repos.d/CentOS-Base.repo
# 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/
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/
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/
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/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[root@localhost ~]#

在此文件中取消注释 baseurl/etc/yum.repos.d/CentOS-Base.repo

#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/

在此区块中:

[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/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

取消注释,我的意思是将此更改为:#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/,更改为:baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/(删除 #)。

问题出在 dhcp 的配置上,尝试输入

dhclient

检查您的 resolv.conf 以查看您的名称服务器指向何处。确保它是合法的,因为我的指向网络上已被清除的旧 DNS 服务器。我用新的 IP 地址更新了它,瞧!

首先,我能够使用 "dhclient" 解决上述问题。但是你每次重新启动时都必须运行这个命令。 这可能是因为您的以太网被禁用,您必须明确启用它。 Click here to see the reason。为了永久修复,我编辑了 /etc/sysconfig/network-scripts/ifcfg-{YOURETHERNET}(在我的例子中是 /etc/sysconfig/network-scripts/ifcfg-eth0)并更改了 ONBOOT=yes 和 boom!!!

是通过

安装ius-release.rpm后/etc/yum.repos.d/epel.repo中https连接出现的错误
sudo yum install -y https://centos7.iuscommunity.org/ius-release.rpm

您需要在 /etc/yum.repos.d/epel.repo 中执行以下操作。

baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch
#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch

取消注释 baseurl 和以 mirrorlist= 开头的注释行。

我来到这里是因为我为不同的依赖项添加了一个错误的镜像(乘客,对于 Rails 应用程序),并通过删除错误的镜像解决了这个问题:

rm /etc/yum.repos.d/YOUR-BAD-DEPENDENCY-NAME.repo

例如

rm /etc/yum.repos.d/passenger.repo

如果有问题的 yum 存储库实际上脱机或没有正确响应,也会发生此问题。

诊断起来可能有点棘手,但 yum 存储库可能会响应 ping 并响应基础 URL 上的 Web 请求,但无法正确提供包。

为了找到有问题的 repo,我发现最好的方法是将每个 repo 文件移出 /etc/yum.repos.d 并移至临时文件夹(例如 /root/yum_bak)和 运行 yum update 删除每个回购协议后。一旦您将有问题的存储库从 /etc/yum.repos.d 中移出,然后 yum update(其他 yum 命令将再次开始正常工作。将工作中的 yum 存储库移回 /etc/yum.repos.d,然后您又回到了业务。

请不要忘记在中断结束后将有问题的存储库移回 /etc/yum.repos.d

sudo sed -i 's/https/http/g' /etc/yum.repos.d/epel.repo

在使用

添加 EPEL 存储库后,我在使用 MITM 代理的公司环境中遇到了这个问题
yum install epel-release

以前不会发生这种情况(例如 yum update)。我检查了所有答案,其中 none 解决了我的问题。 发现其他仓库默认使用 http,epel 使用 https:

# grep mirror /etc/yum.repos.d/epel.repo
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearch&infra=$infra&content=$contentdir
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearch&infra=$infra&content=$contentdir
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearch&infra=$infra&content=$contentdir

所以我在 CentOS 信任库中复制了我们公司的根 CA 并更新了它:

cp /home/user/my-ca.crt /etc/pki/ca-trust/source/anchors/
update-ca-trust

添加证书后,从 EPEL 存储库更新和安装软件包工作正常!