centos 8 yum source cannot be used problem

Problem: The newly installed centos 8 cannot download and install other software without using wget

Error: Failed to download metadata for repository 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist


Solution:

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-x86_64-kernel.repo
[root@localhost yum.repos.d]# mkdir yum
[root@localhost yum.repos.d]# mv *.repo yum

CentOS 8 Base source download address:

http://mirrors.aliyun.com/repo/Centos-8.repo

Other source download addresses:

http://mirrors.aliyun.com/repo/

After downloading, upload it to the server through a file transfer tool such as Account password to log in to the server)

[root@localhost yum.repos.d]# cd /root/
[root@localhost ~]# ls
anaconda-ks.cfg Centos-8.repo
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# mv /root/Centos-8.repo .

Clean the original yum cache again and create a new yum source

[root@localhost yum.repos.d]# yum clean all
0 files deleted
[root@localhost yum.repos.d]# yum makecache
CentOS-8 - Base - mirrors.aliyun.com 1.5 MB/s | 4.6 MB 00:03
CentOS-8 - Extras - mirrors.aliyun.com 28 kB/s | 10 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.com 937 kB/s | 8.4 MB 00:09
Metadata cache has been established.

An error message is reported when yum clean all & amp; & amp; yum makecache:

Error: Failed to download metadata for warehouse 'base': repomd.xml parser error: Parse error at line: 21 (Opening and ending tag mismatch: link line 0 and head)

Solution:

Restart the server: reboot

After restarting, clean the original yum cache and create a new yum source

[root@localhost yum.repos.d]# yum clean all
0 files deleted
[root@localhost yum.repos.d]# yum makecache
CentOS-8 - Base - mirrors.aliyun.com 993 kB/s | 4.6 MB 00:04
CentOS-8 - Extras - mirrors.aliyun.com 14 kB/s | 10 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.com 765 kB/s | 8.4 MB 00:11
Metadata cache has been established.

Test:

[root@localhost yum.repos.d]# yum -y install lrzsz
The last metadata expiration check: 0:06:43 ago, executed at 16:10:00 on Friday, October 27, 2023.
Dependencies are resolved.
================================================== ================================================== ================================================== ====================
 Package Architecture Version Repository Size
================================================== ================================================== ================================================== ====================
Install:
 lrzsz x86_64 0.12.20-43.el8 base 84k

transaction summary
================================================== ================================================== ================================================== ====================
Install 1 package

Total downloads: 84k
Install size: 190k
Download the package:
lrzsz-0.12.20-43.el8.x86_64.rpm 173 kB/s | 84 kB 00:00
-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -------------------
Total 173 kB/s | 84 kB 00:00
retrieving repo key for base unencrypted from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
CentOS-8 - Base - mirrors.aliyun.com 3.6 kB/s | 1.6 kB 00:00
Import GPG public key 0x8483C65D:
 Userid: "CentOS (CentOS Official Signing Key) <[email protected]>"
 Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
 From: http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
Import public key successfully
Run transaction check
Transaction check successful.
Run transaction tests
Transaction test successful.
Run transaction
  In preparation: 1/1
  Installation: lrzsz-0.12.20-43.el8.x86_64 1/1
  Run script: lrzsz-0.12.20-43.el8.x86_64 1/1
  Verification: lrzsz-0.12.20-43.el8.x86_64 1/1

Installed:
  lrzsz-0.12.20-43.el8.x86_64

complete! 

The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Cloud native entry-level skills treeHomepageOverview 16,790 people are learning the system