Centos7更换yum镜像源

刺骨的言语ヽ痛彻心扉 2022-10-17 13:56 372阅读 0赞

Centos7更换yum镜像源

1、首先备份/etc/yum.repos.d/CentOS-Base.repo

  1. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2、下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
以CentOS7-Base-163.repo为例

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12. [base]
  13. name=CentOS-$releasever - Base - 163.com
  14. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  15. baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
  16. gpgcheck=1
  17. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  18. #released updates
  19. [updates]
  20. name=CentOS-$releasever - Updates - 163.com
  21. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  22. baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
  23. gpgcheck=1
  24. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  25. #additional packages that may be useful
  26. [extras]
  27. name=CentOS-$releasever - Extras - 163.com
  28. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  29. baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
  30. gpgcheck=1
  31. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
  32. #additional packages that extend functionality of existing packages
  33. [centosplus]
  34. name=CentOS-$releasever - Plus - 163.com
  35. baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
  36. gpgcheck=1
  37. enabled=0
  38. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

注意文件中$releasever有可能对应不上要手动写死
3、运行以下命令生成缓存

  1. yum clean all
  2. yum makecache

4、yum代理
在/etc/yum.conf中加入下面几句.

  1. vim /etc/yum.conf
  2. proxy=http://210.45.72.XX:808
  3. proxy_username=username
  4. proxy_password=password

发表评论

表情:
评论列表 (有 0 条评论,372人围观)

还没有评论,来说两句吧...

相关阅读

    相关 CentOS7更换yum镜像

    目录 •写在前面 •具体步骤 -------------------- •写在前面 更换镜像源的理由总是惊人的相似,都是因为访问国外的网速不好,所以我们选择更换成

    相关 Centos7 更换yum

    背景   Centos 7默认的yum源网络不好使,所以更改yum源为阿里云 解决方案          命令,可选两种方式均可以,此种命令更换源为阿里云    一