1. 程式人生 > 其它 >CentOS 6.x 版本於2020年11月30日無法正常使用yum安裝命令的解決方法

CentOS 6.x 版本於2020年11月30日無法正常使用yum安裝命令的解決方法

技術標籤:錯誤問題專欄linuxcentosyum

1. 遇到的問題

在搭建Linux叢集環境時,有一個步驟是通過網路,使所有主機和時鐘同步伺服器保持同步。這時需要安裝ntp,然後發現與yum相關的所有操作都報如下錯誤。

##安裝ntp
yum install -y ntp
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 retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

2. 出現該問題的原因

CentOS 6.x 版本在2020年11月30日停止了維護更新,官方源已經沒有用了,映象源也沒用了,需要替換新的源 vault.centos.org

3. 解決該問題方法

3.1 修改 /etc/yum.repos.d 中的 CentOS-Base.repo檔案

cd /etc/yum.repos.
d vim CentOS-Base.repo

修改內容如下(一般需要重複修改5次):
①註釋所有的 mirrorlist
②取消所有 baseurl 的註釋
③將 baseurl 中的mirror.centos.org 改為 vault.centos.org

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/contrib/$basearch/