【微知】如何将Centos8的yum镜像更换为阿里云的镜像?(/etc/yum.repos.d/CentOS-Base.repo, yum clean all, yum makecache)

背景

Centos官方镜像使用yum安装软件经常网络不可达,比如报错:

[root@localhost egypt-1.10]# yum install cpan
CentOS Stream 8 - AppStream 0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository ‘appstream’:
- Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

将yum镜像源换成阿里云比较方便,本文简单记录更换方式。具体可参考:https://developer.aliyun.com/mirror/centos

实操

备份原有以及下载新的

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

在这里插入图片描述

清除原来的以及生成cache

yum clean all && yum makecache

如果还有访问centos官网的,可以直接到yum repos配置目录先移动或者删掉其他的repos

  • 报错
    在这里插入图片描述

  • 查看:
    在这里插入图片描述

  • 移动然后执行makecache
    在这里插入图片描述

然后执行原来报错的安装包

在这里插入图片描述
在这里插入图片描述

综述

  • 删除原有的/etc/yum.repos.d/CentOS-Base.repo
  • yum clean all清除原有数据
  • yum makecache重新生成缓存
  • 安装需要的命令
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值