CentOS8无法安装软件和更新-换源解决

报错如下

Failed to synchronize cache for repo ‘AppStream’, ignoring this repo.
Failed to synchronize cache for repo ‘BaseOS’, ignoring this repo.

由于无法连接官方网站导致,切换国内镜像源即可

国内源:

  • 阿里yum源:mirrors.aliyun.com
  • 腾讯yum源:mirrors.cloud.tencent.com
  • 网易yum源:mirrors.163.com
  • 清华yum源:mirrors.tuna.tsinghua.edu.cn

操作

将代码中替换相应源即可

sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://mirrors.aliyun.com|g' /etc/yum.repos.d/CentOS-*

yum clean all
yum makecache

注意,部分更新后可能还有新的文件出现,此时可以再次执行一次上述操作即可

Author: thinkwei

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注