CentOS 7.2:Yum 儲存庫設定失敗

CentOS 7.2:Yum 儲存庫設定失敗

全新安裝 CentOS 7.2.1511。伺服器最初配置有網路管理器,且 yum 工作正常。最近停用網路管理員並使用傳統服務(/etc/sysconfig/network-scripts)設定網路。新的 IP 位址已指派給 NIC。安裝程式最初位於 10.xxx 網路上,現在位於 192.168.xx 網路上。

當我嘗試執行 yum 時,出現以下錯誤:

Loaded plugins: fastestmirror, langpacks
http://mirror.centos.org/centos/%24releasever/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

http://mirror.centos.org/centos/%24releasever/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.


 One of the configured repositories failed (CentOS-$releasever - Extras),
 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 extras

 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=extras.skip_if_unavailable=true

failure: repodata/repomd.xml from extras: [Errno 256] No more mirrors to try.
http://mirror.centos.org/centos/$releasever/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

以下是網路介面的設定。 em1 和 em2 具有相同的基本配置:

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
NAME=em1
NM_CONTROLLED=no
IPV4_FAILURE_FATAL=no
UUID=d67971e8-846d-428c-9a1d-ff2768ae6ddb
DEVICE=em1
HWADDR=14:18:77:69:D5:DB
ONBOOT=yes
IPADDR=192.168.x.x
NETMASK=255.255.255.0
GATEWAY=192.168.x.x

我的 /etc/hosts 檔案:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.x.x hostname

我的 /etc/resolv.conf 檔案:

nameserver 68.105.28.12
nameserver 68.105.29.11

我的 CentOS-Base.repo 檔案。我取消了 baseurl 設定的註釋,看看這是否有效:

# 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
skip_if_unavailable = 1
keepcache = 0

#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

yum repolist 的結果:

Loaded plugins: fastestmirror, langpacks
http://mirror.centos.org/centos/%24releasever/os/x86_64/repodata/repomd.xml:   [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article 

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please create a bug on   https://bugs.centos.org/

  http://mirror.centos.org/centos/%24releasever/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirror.centos.org/centos/%24releasever/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirror.centos.org/centos/%24releasever/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
repo id                                                                           repo name                                                                         status
extras/$releasever/x86_64                                                       CentOS-$releasever - Extras                                                   0
updates/$releasever/x86_64                                                  CentOS-$releasever - Updates                                                  0
repolist: 0

捲曲結果:

curl 'http://mirrorlist.centos.org/?release=6&arch=i386&repo=os'
http://mirrors.usc.edu/pub/linux/distributions/centos/6.8/os/i386/
http://mirror.lug.udel.edu/pub/centos/6.8/os/i386/
http://mirrors.lga7.us.voxel.net/centos/6.8/os/i386/
http://mirror.chpc.utah.edu/pub/centos/6.8/os/i386/
http://centos.unixheads.org/6.8/os/i386/
http://centos.mirror.lstn.net/6.8/os/i386/
http://centos.mirror.nac.net/6.8/os/i386/
http://mirror.tocici.com/centos/6.8/os/i386/
http://mirror.supremebytes.com/centos/6.8/os/i386/
http://mirror.steadfast.net/centos/6.8/os/i386/

我可以 ping 外部主機並且可以挖掘網域:

dig cnn.com

; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.3 <<>> cnn.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29420
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;cnn.com.           IN  A

;; ANSWER SECTION:
cnn.com.        156 IN  A   157.166.226.26
cnn.com.        156 IN  A   157.166.226.25

;; Query time: 1 msec
;; SERVER: 68.105.28.12#53(68.105.28.12)
;; WHEN: Mon Jun 20 12:28:44 EDT 2016
;; MSG SIZE  rcvd: 68

我確信這與 em1 和 em2 的舊配置有關,當時它們綁定到不同的 IP 位址,但我不知道還能在哪裡查看。我可能缺少什麼才能讓 yum 正常工作?

答案1

經過更多的偵查,我弄清楚了。缺少目錄層次結構,且 yum 無法偵測到我的 CentOS 版本。執行以下命令即可修復此問題:

mkdir -p /etc/yum/vars
echo 7.2.1511 > /etc/yum/vars/releasever

如果您遇到此問題且其他方法都不起作用,請將「7.2.1511」替換為您自己的發行版本。

2017 年 5 月 21 日更新:「7.2.1511」路徑已被棄用。如果您仍在 CentOS 7.2.1511 上,請執行以下命令以保持 yum 工作:

echo 7 > /etc/yum/vars/releasever

如果您突然發現 yum 停止工作,應該可以解決這個問題。

答案2

來源

解決方法是執行以下命令。

rm -fr /var/cache/yum/x86_64/7
yum clean all

這對我有用。 CentOS Linux 版本 7.2.1511(核心)

答案3

http://mirror.centos.org/centos/%24releasever/os/x86_64/repodata/repomd.xml:[Errno 14] HTTP 錯誤 404 - 找不到正在嘗試其他鏡像。

這準確地告訴了您需要了解的內容。

[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
skip_if_unavailable = 1
keepcache = 0

#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

請注意問號和參數之間的空格。

http://mirrorlist.centos.org/?發布=$releasever&arch=$basearch&repo=os&infra=$infra

和選項卡

鏡像列表=http://mirrorlist.centos.org/?發布=$releasever&arch=$basearch&repo=更新&infra=$infra

?您需要做的是刪除和之間的空格release

相關內容