CentOS 7更新为阿里云yum源

时间:2022-06-01 17:04:38

进入yum源的目录

centos 7yum源目录为/etc/yum.repos.d

$cd /etc/yum.repos.d

备份yum源

在更新centos 7的yum源前先备份。

$ sudo cp CentOS-Base.repo backup/

如果没有bakcup目录先创建。

下载阿里云yum源

阿里云yum源列表:http://mirrors.aliyun.com/repo/,centos 7yum源文件为Centos-7.repo。

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

重建yum缓存

更新yum源后需要重建yum的缓存。

清除旧的缓存

$sudo yum clean all

重建新的缓存

$ sudo yum makecache