Centos yum 安装错误
Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist
错误内容:
在使用linux的时候总是习惯的使用clear命令,但是突然发现无法使用了,命令不但没有找到,yum也用不了了,出现了AppStream的奇怪现象!
[root@dfe60f319a2a home]# clear
bash: clear: command not found
[root@dfe60f319a2a home]# yum install ncurses
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 40 B/s | 38 B 00:00
[root@dfe60f319a2a home]# yum list
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 50 B/s | 38 B 00:00
产生原因
CentOS Linux 8早夭了,它在 2021 年 12 月 31 日达到了生命周期结束(EOL),因此它不再从官方 CentOS 项目获得开发资源。这意味着在 2021 年 12 月 31 日之后,要更新您的 CentOS 安装,您需要将镜像更改为CentOS Vault Mirror,它们将永久存档。
因此需要修改仓库的URL
解决方案
跳转到 /etc/yum.repos.d/ 里面
[root@dfe60f319a2a etc]# cd /etc/yum.repos.d/
[root@dfe60f319a2a yum.repos.d]# ls
CentOS-Linux-AppStream.repo CentOS-Linux-ContinuousRelease.repo CentOS-Linux-Devel.repo CentOS-Linux-FastTrack.repo CentOS-Linux-Media.repo CentOS-Linux-PowerTools.repo
CentOS-Linux-BaseOS.repo CentOS-Linux-Debuginfo.repo CentOS-Linux-Extras.repo CentOS-Linux-HighAvailability.repo CentOS-Linux-Plus.repo CentOS-Linux-Sources.repo
然后先后执行下面两个命令
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
[root@dfe60f319a2a yum.repos.d]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
[root@dfe60f319a2a yum.repos.d]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
之后再去查看yum list 就会自动下载了
[root@dfe60f319a2a yum.repos.d]# yum list
Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream 673 kB/s | 8.4 MB 00:12
CentOS Linux 8 - BaseOS 481 kB/s | 4.6 MB 00:09
CentOS Linux 8 - Extras 2.0 kB/s | 10 kB 00:05
Last metadata expiration check: 0:00:01 ago on Wed Nov 23 11:27:54 2022.
Installed Packages
acl.x86_64 2.2.53-1.el8 @System
audit-libs.x86_64 3.0-0.17.20191104git1c2f876.el8 @System
basesystem.noarch 11-5.el8 @System
bash.x86_64 4.4.19-14.el8 @System
bind-export-libs.x86_64 32:9.11.26-3.el8 @System
binutils.x86_64 2.30-93.el8 @System
bzip2-libs.x86_64 1.0.6-26.el8 @System
ca-certificates.noarch 2020.2.41-80.0.el8_2 @System
................
最终centos安装clear的命令如下
一路全部选择y,最后等待即可使用
yum install ncurses