CentOS7快速更改yum源

服务器   发布日期:2025年05月10日   浏览次数:232
  1. yum install wget -y
    rm -rf /etc/yum.repos.d/*
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
    OR
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    修改name和baseurl中的” $releasever”关键字,全换成7。

    删掉里面的http://mirrors.aliyuncs.com/centos/7/os/$basearch/ yum源地址。

  1. yum clean all
  2. yum makecache

 或者更换以下代码:

  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=CentOS7 - Base - mirrors.aliyun.com
  14. failovermethod=priority
  15. baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
  16. http://mirrors.cloud.aliyuncs.com/centos/7/os/$basearch/
  17. gpgcheck=
  18. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  19. #released updates
  20. [updates]
  21. name=CentOS7 - Updates - mirrors.aliyun.com
  22. failovermethod=priority
  23. baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
  24. http://mirrors.cloud.aliyuncs.com/centos/7/updates/$basearch/
  25. gpgcheck=
  26. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  27. #additional packages that may be useful
  28. [extras]
  29. name=CentOS7 - Extras - mirrors.aliyun.com
  30. failovermethod=priority
  31. baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
  32. http://mirrors.cloud.aliyuncs.com/centos/7/extras/$basearch/
  33. gpgcheck=
  34. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  35. #additional packages that extend functionality of existing packages
  36. [centosplus]
  37. name=CentOS7 - Plus - mirrors.aliyun.com
  38. failovermethod=priority
  39. baseurl=http://mirrors.aliyun.com/centos/7/centosplus/$basearch/
  40. http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/$basearch/
  41. gpgcheck=
  42. enabled=
  43. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  44. #contrib - packages by Centos Users
  45. [contrib]
  46. name=CentOS7 - Contrib - mirrors.aliyun.com
  47. failovermethod=priority
  48. baseurl=http://mirrors.aliyun.com/centos/7/contrib/$basearch/
  49. http://mirrors.cloud.aliyuncs.com/centos/7/contrib/$basearch/
  50. gpgcheck=
  51. enabled=
  52. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

 

以上就是CentOS7快速更改yum源的详细内容,更多关于CentOS7快速更改yum源的资料请关注九品源码其它相关文章!