如果CentOS6系的yum返回404错误(2020/3版)

请注意

    2023/10/05現在、以下のURLは使えなくなっています。詳しくはこちら

    2023/10現在、こちらの方の記事が有効であることを確認しました

    CentOS6系の場合、同記事URL内の 5.10 を任意の値(例: 6.10)に書き換えれば機能します

首先

尽管理应不再使用CentOS 6,但令人伤心的是我这次不得不碰到它。而且,yum立刻就无法运行了。。。类似的问题似乎很常见,在网上也有很多类似的信息散见。

    CentOS6.7でyumのアップデートが失敗する[Errno 14]
    CentOS6.7で[Errno 14] PYCURL ERROR 22 – “The requested URL returned error: 404 Not Found”とかいうエラーがでた
    [tips][Linux]旧バージョンCentOSでyum更新できなくなった時

然而,根据上述的网站信息已经过时,对于我的环境而言无法运行,因此我将留下2020年3月的最新信息。

解决方法

将存储有用于yum的信息的文件/etc/yum.repos.d/CentOS-Base.repo按照以下方式修改。

    各項目の mirrorlist をコメントアウトして、baseurl をアンコメント。

    baseurl の参照先を http://mirror.centos.org/centos/6/[項目名]/x86_64/ へ変更

    centosplus, contrib は不要な気もしますが、念の為

# 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-6.10 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=6.10&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirror.centos.org/centos/6/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=6.10&arch=$basearch&repo=updates&infra=$infra
baseurl=http://mirror.centos.org/centos/6/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=6.10&arch=$basearch&repo=extras&infra=$infra
baseurl=http://mirror.centos.org/centos/6/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=6.10&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://mirror.centos.org/centos/6/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=6.10&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://mirror.centos.org/centos/6/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

以上的内容适用于CentOS 6.10,但存储库本身似乎适用于6系列共用(?)。

bannerAds