1. 备份
1 | mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup |
2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
CentOS 6
1 | wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo |
或者
1 | curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo |
CentOS 7
1 | wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo |
或者
1 | curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo |
CentOS 8
1 | wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo |
或者
1 | curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo |
3. 更新镜像源
清除缓存:
1 | yum clean all |
生成缓存:
1 | yum makecache |
4. 更改配置文件
打开 CentOS-Base.repo 文件,
1 | vi /etc/yum.repos.d/CentOS-Base.repo |
或
1 | vim /etc/yum.repos.d/CentOS-Base.repo |
将文件中的所有http
开头的地址更改为https
1 | # CentOS-Base.repo |
5. 更新yum
1 | yum update |