【虚拟机安装centos7.6 yum使用报错 配置镜像源 错误记录】

错误

[root@localhost ~]# yum -y update
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:
 1. Contact the upstream for the repository and get them to fix the problem.
 2. Reconfigure the baseurl/etc. for the repository, to point to a working
 upstream. This is most often useful if you are using a newer
 distribution release than is supported by the repository (and the
 packages for the previous distribution release still work).
 3. Run the command with the repository temporarily disabled
 yum --disablerepo= ...
 4. Disable the repository permanently, so yum won't use it by default. Yum
 will then just ignore the repository until you permanently enable it
 again or use --enablerepo for temporary usage:
 yum-config-manager --disable
 or
 subscription-manager repos --disable=
 5. Configure the failing repository to be skipped, if it is unavailable.
 Note that yum will try to contact the repo. when it runs most commands,
 so will have to try and fail each time (and thus. yum will be be much
 slower). If it is a very temporary problem though, this is often a nice
 compromise:
 yum-config-manager --save --setopt=.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base

清华大学镜像源:

# CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

中科大镜像源:

# CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

操作替换

  1. 备份当前的仓库配置:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 创建新的仓库配置文件:
vi /etc/yum.repos.d/CentOS-Base.repo
  1. 将上面的任一配置粘贴到这个文件中。
    保存并退出编辑器。
    清理 yum 缓存并重新生成:
yum clean all
yum makecache
  1. 尝试安装软件包:
yum install yum-utils

相关推荐

  1. 【笔记】在虚拟中输入 yum makecache

    2024-07-09 17:02:05       25 阅读
  2. centos7安装docker(包含yum配置阿里云镜像

    2024-07-09 17:02:05       57 阅读
  3. 配置yum镜像

    2024-07-09 17:02:05       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 17:02:05       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 17:02:05       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 17:02:05       58 阅读
  4. Python语言-面向对象

    2024-07-09 17:02:05       69 阅读

热门阅读

  1. Fedora 41 移除 Python 2支持

    2024-07-09 17:02:05       26 阅读
  2. 单例模式之懒汉式

    2024-07-09 17:02:05       30 阅读
  3. 代码技巧专题 -- 使用策略模式编写HandleService

    2024-07-09 17:02:05       29 阅读
  4. 汇编学习基础知识【记录】

    2024-07-09 17:02:05       26 阅读
  5. mapper.xml 文件对应的 Dao 接口原理

    2024-07-09 17:02:05       25 阅读
  6. Linux服务监控自动巡检脚本--推送钉钉告警

    2024-07-09 17:02:05       34 阅读
  7. stm32中断

    2024-07-09 17:02:05       26 阅读
  8. 使用引用 XML 文件来优化 EtherCAT ESI 文件的描述

    2024-07-09 17:02:05       33 阅读
  9. uni app for()在App上不运行

    2024-07-09 17:02:05       25 阅读
  10. OpenSNN推文:盛夏智慧之光:七月高校新闻聚焦

    2024-07-09 17:02:05       33 阅读
  11. 【计算机网络——1.2网络边缘】

    2024-07-09 17:02:05       34 阅读