The source of yum/dnf in the official centos mirror is commented out by default. If it is used directly, the following error will appear
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
The repair method is to modify the source configuration file under **/etc/yum.repos.d/**,
If it is domestic, it can be replaced by domestic sources;
wget -O /etc/yum.repos.d/CentOS7-Aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo
In China, you can choose such as Ali's repo
Domestic yum source:
Ali yum source: http://mirrors.aliyun.com/repo/
163 (NetEase) yum source: http://mirrors.163.com/.help/
Linux installation mirror source of University of Science and Technology of China: http:/ /centos.ustc.edu.cn/Sohu’s
Linux installation mirror source: http://mirrors.sohu.com/Beijing
Capital Online Technology: http://mirrors.yun-idc.com/
If it is overseas, you can directly remove the comment.
You can use the following commands to operate:
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-*