• 中文
    • English
  • 注册
    • 查看作者
    • Linux报错Could not retrieve mirrorlist http://mirrorlist.centos.org

      1、备份当前的yum仓库配置:

      sudo cp -ar /etc/yum.repos.d /etc/yum.repos.d.bak

      2、宝塔面板 → 文件,打开以下文件:

      /etc/yum.repos.d/CentOS-Base.repo
      /etc/yum.repos.d/CentOS-CR.repo
      /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
      /etc/yum.repos.d/CentOS-fasttrack.repo

      3、注释掉mirrorlist项,启用baseurl项,并把baseurl项的镜像源地址修改为阿里云mirrors.aliyun.com,如下图:

      Linux报错Could not retrieve mirrorlist http://mirrorlist.centos.org

      Centos7.6系统的CentOS-Base.repo文件代码如下:

      # CentOS-Base.repo
      #
      # The mirror system uses the connecting IP address of the client and the
      # update status of each mirror to pick mirrors that are updated to and
      # geographically close to the client.  You should use this for CentOS updates
      # unless you are manually picking other mirrors.
      #
      # If the mirrorlist= does not work for you, as a fall back you can try the 
      # remarked out baseurl= line instead.
      #
      #
      [base]
      name=CentOS-$releasever - Base - 163.com
      #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
      baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
      
      #released updates
      [updates]
      name=CentOS-$releasever - Updates - 163.com
      #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
      baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
      
      #additional packages that may be useful
      [extras]
      name=CentOS-$releasever - Extras - 163.com
      #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
      baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
      gpgcheck=1
      gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
      
      #additional packages that extend functionality of existing packages
      [centosplus]
      name=CentOS-$releasever - Plus - 163.com
      baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
      gpgcheck=1
      enabled=0
      gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

      4、清除缓存并重新构建yum源:

      yum clean all
      yum clean dbcache
      yum makecache

    • 3
    • 1
    • 0
    • 125
    • 巅峰,无名似水流年(♛‿♛)

      请登录之后再进行评论

      登录
    • 1
      三七少侠永恒之主
      Linux需要安装环境的,就容易遇到这个问题!(收藏记录)
    • 返回顶部
    • 做任务
    • 实时动态
    • 偏好设置
    • 到底部
    • 单栏布局 侧栏位置: