Centos7、Centos8更换yum源

Centos7、Centos8更换yum源

Centos7、Centos8更换yum源

Centos8

将源文件备份

cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/

下载阿里源文件

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

更新源文件中的地址

sed -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*
sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*

生成缓存

yum clean all && yum makecache

Centos7

备份源文件

cd /etc/yum.repos.d/ && mkdir backup && mv *repo backup/

下载安装阿里云镜像仓库

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

下载安装阿里云epel.repo

sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

清理缓存、更新缓存并生成更新

yum clean all && yum makecache && yum makecache fast && yum update -y
Comment