生产环境搭建收藏本版 +发表新主题

如何把CentOS默认镜像源更换为阿里云镜像源

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/
  1. CentOS 5
  2. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
  3. 或者
  4. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
  5. CentOS 6
  6. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  7. 或者
  8. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
  9. CentOS 7
  10. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  11. 或者
  12. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  13. CentOS 8
  14. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  15. 或者
  16. curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
3.之后先清除缓存再生成缓存
  1. # 清除缓存
  2. yum clean all
  3. # 生存缓存
  4. yum makecache
4.Epel 镜像
1. 备份(如有配置其他epel源)
  1. mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
  2. mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
2.下载新repo 到/etc/yum.repos.d/
epel(RHEL 8)
1)安装 epel 配置包
  1. yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
2)将 repo 配置中的地址替换为阿里云镜像站地址
  1. sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
  2. sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
epel(RHEL 7)
  1. wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

扫描二维码,手机查看
声明:本文来源于互联网,观点仅代表作者本人,不代表欢乐你我,真实性请妥善甄别。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则