CentOS Linux 8 - AppStream 错误:为仓库 ‘appstream‘ 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs

问题描述
今天2022年3月7日在CentOS 8.2上安装软件时,遇到如下报错:


CentOS Linux 8 - AppStream 错误:为仓库 ‘appstream’ 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist

在网上一顿搜索也没能解决,最终在阿里云开发者社区找到了答案!网址为:https://developer.aliyun.com/mirror/centos

问题原因
CentOS Linux 8在2022年12月31日来到生命周期终点(End of Life,EoL)。即CentOS Linux 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。所以原来的CentOS Linux 8的yum源也都失效了!最终导致此问题的产生。

问题解决方法
更换CentOS Linux 8的yum源

1、切换到源目录,备份原来的源

[root@VM-16-7-centos ~]#  yum module list nodejs
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository epel is listed more than once in the configuration
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
CentOS Linux 8 - AppStream                                                                                                    69  B/s |  38  B     00:00    
错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs in mirrorlist
[root@VM-16-7-centos ~]# cd /etc/yum.repos.d/
[root@VM-16-7-centos yum.repos.d]# ls -l
总用量 136
-rw-r--r-- 1 root root 15075 3月   5 14:29 centos8-repo.zip
-rw-r--r-- 1 root root   250 3月   5 14:45 CentOS-AppStream.repo
-rw-r--r-- 1 root root   228 10月 26 2020 CentOS-AppStream.repo.rpmsave
-rw-r--r-- 1 root root  2495 2月  14 21:16 CentOS-Base.repo
-rw-r--r-- 1 root root   214 10月 26 2020 CentOS-Base.repo.rpmsave
-rw-r--r-- 1 root root   226 10月 26 2020 CentOS-centosplus.repo.rpmsave
-rw-r--r-- 1 root root   249 10月 26 2020 CentOS-Devel.repo.rpmsave
-rw-r--r-- 1 root root   231 3月   5 14:26 CentOS-Epel.repo
-rw-r--r-- 1 root root   216 10月 26 2020 CentOS-Extras.repo.rpmsave
-rw-r--r-- 1 root root   232 10月 26 2020 CentOS-HA.repo.rpmsave
-rw-r--r-- 1 root root   719 9月  15 09:11 CentOS-Linux-AppStream.repo
-rw-r--r-- 1 root root   704 9月  15 09:11 CentOS-Linux-BaseOS.repo
-rw-r--r-- 1 root root  1130 9月  15 09:11 CentOS-Linux-ContinuousRelease.repo
-rw-r--r-- 1 root root   318 9月  15 09:11 CentOS-Linux-Debuginfo.repo
-rw-r--r-- 1 root root   732 9月  15 09:11 CentOS-Linux-Devel.repo
-rw-r--r-- 1 root root   704 9月  15 09:11 CentOS-Linux-Extras.repo
-rw-r--r-- 1 root root   719 9月  15 09:11 CentOS-Linux-FastTrack.repo
-rw-r--r-- 1 root root   740 9月  15 09:11 CentOS-Linux-HighAvailability.repo
-rw-r--r-- 1 root root   693 9月  15 09:11 CentOS-Linux-Media.repo
-rw-r--r-- 1 root root   706 9月  15 09:11 CentOS-Linux-Plus.repo
-rw-r--r-- 1 root root   724 9月  15 09:11 CentOS-Linux-PowerTools.repo
-rw-r--r-- 1 root root  1124 9月  15 09:11 CentOS-Linux-Sources.repo
-rw-r--r-- 1 root root   231 10月 26 2020 CentOS-PowerTools.repo.rpmsave
-rw-r--r-- 1 root root  1485 9月   5 2021 epel-modular.repo
-rw-r--r-- 1 root root  1564 9月   5 2021 epel-playground.repo
-rw-r--r-- 1 root root  1422 9月   5 2021 epel.repo
-rw-r--r-- 1 root root  1584 9月   5 2021 epel-testing-modular.repo
-rw-r--r-- 1 root root  1521 9月   5 2021 epel-testing.repo
-rw-r--r-- 1 root root   448 11月 13 01:46 mysql-community.repo
-rw-r--r-- 1 root root   427 11月 15 14:39 nginx.repo
-rw-r--r-- 1 root root   474 4月  17 2020 nodesource-el8.repo
[root@VM-16-7-centos yum.repos.d]# mkdir bak
[root@VM-16-7-centos yum.repos.d]# mv CentOS-* bak


2、下载新的源文件,并用命令yum makecache建立新的元数据缓存

下载源文件命令:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
 

[root@VM-16-7-centos yum.repos.d]# rm -rf *
[root@VM-16-7-centos yum.repos.d]# ls
[root@VM-16-7-centos yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
--2022-03-07 09:13:32--  https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 122.225.209.208, 122.225.209.209, 122.228.195.210, ...
正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|122.225.209.208|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2495 (2.4K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

/etc/yum.repos.d/CentOS-Base.repo       100%[============================================================================>]   2.44K  --.-KB/s  用时 0.009s  

2022-03-07 09:13:32 (286 KB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2495/2495])

[root@VM-16-7-centos yum.repos.d]# ls
CentOS-Base.repo
[root@VM-16-7-centos yum.repos.d]# vim CentOS-Base.repo 
[root@VM-16-7-centos yum.repos.d]# yum makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                                                                                  105 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                                                                 39 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                                                             441 kB/s | 8.4 MB     00:19    
元数据缓存已建立。


3、测试源(用yum命令装个软件试试)

[root@VM-16-7-centos yum.repos.d]# yum  yum module list nodejs
未找到命令: yum。请使用 /usr/bin/yum --help
它可能是一个YUM插件命令,尝试:"yum install 'dnf-command(yum)'"
[root@VM-16-7-centos yum.repos.d]# dnf update -y
上次元数据过期检查:0:01:10 前,执行于 2022年03月07日 星期一 09时14分09秒。
依赖关系解决。
无需任何处理。
完毕!
[root@VM-16-7-centos yum.repos.d]# sudo yum -y install curl
上次元数据过期检查:0:02:29 前,执行于 2022年03月07日 星期一 09时14分09秒。
软件包 curl-7.61.1-22.el8.x86_64 已安装。
依赖关系解决。
无需任何处理。
完毕!
[root@VM-16-7-centos yum.repos.d]# curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -

## Installing the NodeSource Node.js 14.x repo...


## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release || rpm -q --whatprovides fedora-release
+ uname -m

## Confirming "el8-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## As yum will try to install Node.js from the AppStream repository
instead of the NodeSource repository, the AppStream's version of Node.js has to be disabled.
## Run `sudo yum module enable -y nodejs` to reactivate the AppStream's Node.js repository.

+ yum module disable -y nodejs
上次元数据过期检查:0:02:38 前,执行于 2022年03月07日 星期一 09时14分09秒。
依赖关系解决。
=============================================================================================================================================================
 软件包                               架构                                版本                                    仓库                                  大小
=============================================================================================================================================================
禁用模块:
 nodejs                                                                                                                                                     

事务概要
=============================================================================================================================================================

完毕!

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.Da9dAubFHD' 'https://rpm.nodesource.com/pub_14.x/el/8/x86_64/nodesource-release-el8-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.Da9dAubFHD'

## Cleaning up...

+ rm -f '/tmp/tmp.Da9dAubFHD'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 14.x and npm.
## You may run dnf if yum is not available:
     sudo dnf install -y nodejs
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

[root@VM-16-7-centos yum.repos.d]# ls
CentOS-Base.repo  nodesource-el8.repo
[root@VM-16-7-centos yum.repos.d]# cd /home/
[root@VM-16-7-centos home]# ls
java  jd_script  lighthouse  myfiles  mysql  redis6  redis-6.0.1  redis-6.0.1.tar.gz  ruoyi  sshPrevent  tyn  zengyong  zengyong_root
[root@VM-16-7-centos home]# cd jd_script/
[root@VM-16-7-centos jd_script]# ls
qiandao_jd
[root@VM-16-7-centos jd_script]# sudo yum install -y nodejs
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/nodesource-el8.repo; 配置:ID 为 "failovermethod" 的 OptionBinding 不存在
Node.js Packages for Enterprise Linux 8 - x86_64                                                                             284 kB/s | 1.1 MB     00:03    
上次元数据过期检查:0:00:01 前,执行于 2022年03月07日 星期一 09时17分23秒。
依赖关系解决。
=============================================================================================================================================================
 软件包                          架构                            版本                                              仓库                                 大小
=============================================================================================================================================================
安装:
 nodejs                          x86_64                          2:14.19.0-1nodesource                             nodesource                           33 M

事务概要
=============================================================================================================================================================
安装  1 软件包

总下载:33 M
安装大小:93 M
下载软件包:
nodejs-14.19.0-1nodesource.x86_64.rpm                                                                                        8.9 MB/s |  33 MB     00:03    
-------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                         8.9 MB/s |  33 MB     00:03     
Node.js Packages for Enterprise Linux 8 - x86_64                                                                             1.6 MB/s | 1.6 kB     00:00    
导入 GPG 公钥 0x34FA74DD:
 Userid: "NodeSource <gpg-rpm@nodesource.com>"
 指纹: 2E55 207A 95D9 944B 0CC9 3261 5DDB E8D4 34FA 74DD
 来自: /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
导入公钥成功
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                              1/1 
  运行脚本: nodejs-2:14.19.0-1nodesource.x86_64                                                                                                          1/1 
  安装    : nodejs-2:14.19.0-1nodesource.x86_64                                                                                                          1/1 
  运行脚本: nodejs-2:14.19.0-1nodesource.x86_64                                                                                                          1/1 
  验证    : nodejs-2:14.19.0-1nodesource.x86_64                                                                                                          1/1 

已安装:
  nodejs-2:14.19.0-1nodesource.x86_64                                                                                                                        

完毕!
[root@VM-16-7-centos jd_script]# 


yum源已经可以正常使用了,问题最终得到解决!特此记录,以备查用!

  • 21
    点赞
  • 77
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值