CentOS Linux 8 - AppStream Error: Failed to download metadata for repository 'appstream': Cannot prepare internal mirrorlist: No URLs

Problem Description
When installing software on CentOS 8.2 today, March 7, 2022, the following error was reported:


CentOS Linux 8 - AppStream Error: Failed to download metadata for repository 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

A search on the Internet failed to solve it, and finally found the answer in the Alibaba Cloud developer community! URL: https://developer.aliyun.com/mirror/centos

Cause of the problem
CentOS Linux 8 will come to the end of life cycle (End of Life, EoL) on December 31, 2022. That is, the CentOS Linux 8 operating system version has ended its life cycle (EOL), and the Linux community no longer maintains this operating system version. So the original CentOS Linux 8 yum source is also invalid! eventually lead to this problem.

Solution to the problem
Replace the yum source of CentOS Linux 8

1. Switch to the source directory and back up the original source

[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. Download the new source file and create a new metadata cache with the command yum makecache

Download the source file command:

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. Test source (use the yum command to install a software to try)

[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 <[email protected]>"
 指纹: 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]# 


The yum source is already available for normal use, and the problem has finally been resolved! It is hereby recorded for reference!

Guess you like

Origin blog.csdn.net/u012374381/article/details/79790969