CentOS8 更换阿里云源

由于国内网络原因,如果你的服务器在国内的话,在CentOS上安装一些软件速度可能会很慢,因此我们需要更改系统软件源

建议将yum源改为国内源,比如阿里云,方式如下:\n

yum install wget -y
yum install curl -y

环境: CentOS Linux release 8.1.1911 (Core);

1.备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
mv /etc/yum.repos.d/CentOS-PowerTools.repo /etc/yum.repos.d/CentOS-PowerTools.repo.backup
mv /etc/yum.repos.d/CentOS-Extras.repo.backup /etc/yum.repos.d/CentOS-Extras.repo.backup.backup
mv /etc/yum.repos.d/CentOS-centosplus.repo.repo /etc/yum.repos.d/CentOS-centosplus.repo.backup
mv /etc/yum.repos.d/CentOS-AppStream.repo.repo /etc/yum.repos.d/CentOS-AppStream.repo.backup

以上文件都需要重新命名,因为阿里云源里Centos-8.repo包含了上述所有文件,如果按照传统手法只更改CentOS-Base.repo这个文件 会出现一下提示

Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration

2.修改为阿里云

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

3.运行yum makecache生成缓存

yum clean all
yum makecache
点赞

发表评论

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