欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > Linux系统中更新镜像源时出现Cannot find a valid baseurl for repo centos-sclo-rhx/86_64的解决方案

Linux系统中更新镜像源时出现Cannot find a valid baseurl for repo centos-sclo-rhx/86_64的解决方案

2025/5/3 15:44:23 来源:https://blog.csdn.net/awei0916/article/details/147294724  浏览:    关键词:Linux系统中更新镜像源时出现Cannot find a valid baseurl for repo centos-sclo-rhx/86_64的解决方案

在centos7系统中使用命令sudo yum makecache时,可能会出现以下问题:

[root@localhost yum.repos.d]# sudo yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"One of the configured repositories failed (Unknown),and yum doesn't have enough cached data to continue. At this point the onlysafe 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 workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>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 muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=trueCannot find a valid baseurl for repo: centos-sclo-rh/x86_64

你遇到的错误 Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64 是由于 centos-sclo-rh 仓库的 URL 不可达或配置问题导致的。以下是分步解决方案:


1. 检查网络连接

确保系统可以访问互联网:

ping baidu.com  # 检查网络连通性(按 Ctrl+C 退出)

2. 验证仓库配置

检查仓库配置文件是否存在及配置是否正常:

# 查看 centos-sclo-rh 的配置文件
cat /etc/yum.repos.d/CentOS-SCLo-scl.repo
cat /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
  • 如果文件不存在,说明仓库未安装,需安装 centos-release-scl(见下一步)。
  • 如果存在,检查 baseurlmirrorlist 是否有误。

3. 安装或修复仓库配置

安装 centos-release-scl(关键一步)
sudo yum install -y centos-release-scl

这会为 CentOS 系统添加 centos-sclo-rhcentos-sclo-scl 仓库。


4. 替换为国内镜像源(可选)

如果官方仓库较慢或不可用,建议使用国内镜像(如阿里云、清华源):
阿里云镜像 为例,替换仓库配置:

# 备份原有配置文件
sudo cp /etc/yum.repos.d/CentOS-SCLo-scl.repo /etc/yum.repos.d/CentOS-SCLo-scl.repo.backup
sudo cp /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo.backup# 使用阿里云镜像源
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \-e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.aliyun.com/centos|g' \-i.bak \/etc/yum.repos.d/CentOS-SCLo-scl{,-rh}.repo# 清理缓存并更新
sudo yum clean all
sudo yum makecache

5. 禁用仓库(临时解决方案)

如果仓库暂时不可用且不依赖它,可禁用该仓库:

sudo yum-config-manager --disable centos-sclo-rh

或设置跳过不可用仓库(执行后续操作时不再尝试请求该仓库):

sudo yum-config-manager --save --setopt=centos-sclo-rh.skip_if_unavailable=true

6. 验证修复

# 清理缓存并重新尝试
sudo yum clean all
sudo yum update  # 测试仓库是否正常工作

可能的问题原因

  1. 仓库未启用:未安装 centos-release-scl 软件包。
  2. 镜像站不可达:官方仓库 URL 被防火墙或网络策略阻止。
  3. 过时的 CentOS 版本:旧版 CentOS 可能已停止对某些仓库的支持。

补充说明

  • 若使用代理
    /etc/yum.conf 中配置代理:
    proxy=http://<your-proxy-address>:<port>
    
  • 若需强制使用 HTTPS
    确保系统中已安装 ca-certificates
    sudo yum install -y ca-certificates
    

总结

  1. 首选方案:安装 centos-release-scl 并更新镜像源(步骤3-4)。
  2. 临时方案:禁用仓库或设置跳过(步骤5)。
  3. 网络问题:排查网络或代理设置(步骤1、6)。

完成后,再重新执行之前的构建操作即可! 🚀

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词