解决CentOS 8 yum软件源下载失败的问题
新安装的centos8访问yum源时,常见错误如下:
[root@localhost ~]# yum list
CentOS Linux 8 – AppStream 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository ‘appstream’:
– Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
错误:为仓库 ‘appstream’ 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
可以替换为国内的软件源,比如阿里云的:
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 52
-rw-r–r–. 1 root root 568 11月 2 05:30 CentOS-Base.repo
-rw-r–r–. 1 root root 719 9月 14 2021 CentOS-Linux-AppStream.repo
-rw-r–r–. 1 root root 704 9月 14 2021 CentOS-Linux-BaseOS.repo
-rw-r–r–. 1 root root 1130 9月 14 2021 CentOS-Linux-ContinuousRelease.repo
-rw-r–r–. 1 root root 318 9月 14 2021 CentOS-Linux-Debuginfo.repo
-rw-r–r–. 1 root root 732 9月 14 2021 CentOS-Linux-Devel.repo
-rw-r–r–. 1 root root 704 9月 14 2021 CentOS-Linux-Extras.repo
-rw-r–r–. 1 root root 719 9月 14 2021 CentOS-Linux-FastTrack.repo
-rw-r–r–. 1 root root 740 9月 14 2021 CentOS-Linux-HighAvailability.repo
-rw-r–r–. 1 root root 693 9月 14 2021 CentOS-Linux-Media.repo
-rw-r–r–. 1 root root 706 9月 14 2021 CentOS-Linux-Plus.repo
-rw-r–r–. 1 root root 724 9月 14 2021 CentOS-Linux-PowerTools.repo
-rw-r–r–. 1 root root 1124 9月 14 2021 CentOS-Linux-Sources.repo
先备份原来的软件源到指定目录下:
[root@localhost yum.repos.d]# mkdir yum.bak
[root@localhost yum.repos.d]# ll
总用量 52
-rw-r–r–. 1 root root 568 11月 2 05:30 CentOS-Base.repo
-rw-r–r–. 1 root root 719 9月 14 2021 CentOS-Linux-AppStream.repo
-rw-r–r–. 1 root root 704 9月 14 2021 CentOS-Linux-BaseOS.repo
-rw-r–r–. 1 root root 1130 9月 14 2021 CentOS-Linux-ContinuousRelease.repo
-rw-r–r–. 1 root root 318 9月 14 2021 CentOS-Linux-Debuginfo.repo
-rw-r–r–. 1 root root 732 9月 14 2021 CentOS-Linux-Devel.repo
-rw-r–r–. 1 root root 704 9月 14 2021 CentOS-Linux-Extras.repo
-rw-r–r–. 1 root root 719 9月 14 2021 CentOS-Linux-FastTrack.repo
-rw-r–r–. 1 root root 740 9月 14 2021 CentOS-Linux-HighAvailability.repo
-rw-r–r–. 1 root root 693 9月 14 2021 CentOS-Linux-Media.repo
-rw-r–r–. 1 root root 706 9月 14 2021 CentOS-Linux-Plus.repo
-rw-r–r–. 1 root root 724 9月 14 2021 CentOS-Linux-PowerTools.repo
-rw-r–r–. 1 root root 1124 9月 14 2021 CentOS-Linux-Sources.repo
drwxr-xr-x. 2 root root 6 11月 2 05:35 yum.bak
[root@localhost yum.repos.d]# mv *.repo yum.bak/
[root@localhost yum.repos.d]# ll
总用量 4
drwxr-xr-x. 2 root root 4096 11月 2 05:36 yum.bak
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
–2024-11-02 05:37:00– https://mirrors.aliyun.com/repo/Centos-8.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)… 116.196.135.211, 116.196.135.214, 116.196.135.212, …
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|116.196.135.211|:443… 已连接。
已发出 HTTP 请求,正在等待回应… 200 OK
长度:2590 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
/etc/yum.repos.d/CentOS-Base. 100%[=================================================>] 2.53K –.-KB/s 用时 0s
2024-11-02 05:37:00 (48.4 MB/s) – 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2590/2590])
删除缓存
[root@localhost yum.repos.d]# yum clean all
0 文件已删除
重建缓存
[root@localhost yum.repos.d]# yum -y makecache
CentOS-8 – Base – mirrors.aliyun.com 8.2 MB/s | 4.6 MB 00:00
CentOS-8 – Extras – mirrors.aliyun.com 6.8 kB/s | 10 kB 00:01
CentOS-8 – AppStream – mirrors.aliyun.com 9.2 MB/s | 8.4 MB 00:00
元数据缓存已建立。
[root@localhost yum.repos.d]# yum repolist
仓库 id 仓库名称
AppStream CentOS-8 – AppStream – mirrors.aliyun.com
base CentOS-8 – Base – mirrors.aliyun.com
extras CentOS-8 – Extras – mirrors.aliyun.com
安装宝塔面板测试一下:
[root@localhost yum.repos.d]# yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sudo bash install.sh
上次元数据过期检查:0:01:58 前,执行于 2024年11月02日 星期六 05时37分33秒。
软件包 wget-1.19.5-10.el8.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!
–2024-11-02 05:39:31– http://download.bt.cn/install/install_6.0.sh
正在解析主机 download.bt.cn (download.bt.cn)… 211.99.98.159, 240e:97e:4000:33f:103:212:48:148
正在连接 download.bt.cn (download.bt.cn)|211.99.98.159|:80… 已连接。
已发出 HTTP 请求,正在等待回应… 200 OK
长度:49358 (48K) [application/octet-stream]
正在保存至: “install.sh”
install.sh 100%[=================================================>] 48.20K –.-KB/s 用时 0.09s
2024-11-02 05:39:31 (522 KB/s) – 已保存 “install.sh” [49358/49358])
声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 嗅谱网
转载请注明:转自《解决CentOS 8 yum软件源下载失败的问题》
本文地址:http://www.xiupu.net/archives-11377.html
关注公众号:
微信赞赏
支付宝赞赏