三木

三木

我没有热爱这里,我只是出生在这个地方。

CentOS 6 無法使用 yum 解決辦法

相信已經有很多朋友在連接到 CentOS 6 的伺服器後執行 yum 後發現報錯。這是因為 CentOS 6 已經隨著 2020 年 11 月的結束進入了 EOL(End of Life)。不過,CentOS 官方為不想捨棄 CentOS 6 的使用者保留了最後一個版本的鏡像,但這個鏡像不會再有更新。

一鍵修復#

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo
yum clean all
yum makecache

手動修復教程#

禁用 fastestmirror 插件#

vi /etc/yum/pluginconf.d/fastestmirror.conf
# 修改以下行
enable=0
# 或者執行以下命令
sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf

替換 yum 源#

將之前的 yum 源備份:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

然後選擇以下任一方法來替換為新的 yum 源:

官方 Vault 源(海外伺服器使用)#

curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Official.repo

阿里雲 Vault 鏡像(國內伺服器使用)#

curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo

錯誤詳情#

以下是可能遇到的一些錯誤訊息:

[root@c8-20 ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

或者

[root@li496-237 ~]# yum -y install unzip zip
Loaded plugins: fastestmirror
Setting up Install Process
Determining fastest mirrors
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. Invalid release/repo/arch combination/
http://mirrors.linode.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned 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 open a ticket with Red Hat Support.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。