自学内容网 自学内容网

【虚拟机安装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

原文地址:https://blog.csdn.net/weixin_45561352/article/details/140275729

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!