CentOS 设置 YUM 源

爷,独闯天下 提交于 2019-12-04 19:29:49

备份

  • mkdir /etc/yum.repos.d/bak.d
  • mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak.d/

ISO

如果未连接网络 , 可设置 YUM 源为 ISO 镜像

  • 使用 AUTOFS 自动挂载 ISO 光盘
  • vi /etc/yum.repos.d/iso.repo
    [iso]
    name=iso
    baseurl=file:///misc/cd
    gpgcheck=0
  • yum clean all
  • yum makecache

单个源

  • 视版本下载 YUM 源 REPO 文件
  • mv ?.repo /etc/yum.repos.d/CentOS-Base.repo
  • yum clean all
  • yum makecache

多个源

视版本选择下载 YUM 源 , 比如

  • ll /etc/yum.repos.d/
    -rw-r--r--. 1 root root 1572 Nov 17 03:14 Centos-7.mirrors.163.com.repo
    -rw-r--r--. 1 root root 2523 Nov 17 01:46 Centos-7.mirrors.aliyun.com.repo
    -rw-r--r--. 1 root root 2473 Nov 17 01:45 Centos-7.mirrors.cqu.edu.cn.repo
    -rw-r--r--. 1 root root 1684 Nov 17 03:10 Centos-7.mirrors.neusoft.edu.cn.repo
    -rw-r--r--. 1 root root 1698 Nov 17 00:55 Centos-7.mirrors.tuna.tsinghua.edu.cn.repo
    -rw-r--r--. 1 root root 542 Nov 17 00:37 Centos-7.mirrors.zju.edu.cn.repo
  • yum install -y yum-fastestmirror
    fastestmirror 插件会自动选择最快速的镜像
  • cat /etc/yum/pluginconf.d/fastestmirror.conf
    配置文件
  • find / -name timedhosts.txt
    /var/cache/yum/x86_64/7/timedhosts.txt 速度测试记录文件
  • yum clean all
  • yum makecache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!