CentOS 更换镜像源

1. 备份

[root@localhost yum.repos.d]#  mv CentOS-Base.repo.bak CentOS-Base.repo.backup

2. 下载新的CentOS-Base.repo 到/etc/yum.repos.d目录

  • 阿里镜像地址:https://opsx.alibaba.com/mirror
  • CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
  • CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  • CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3. 生成新的缓存

  • 清楚缓存
[root@localhost yum.repos.d]# yum clean all
  • 生成缓存
[root@localhost yum.repos.d]# yum makecache

你可能感兴趣的:(Linux,CentOS)