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 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=<repoid> ...

     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 <repoid>
        or
            subscription-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 much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot 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)。

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

[root@iZ2zeddv2x94139qgzr55aZ /]# sudo yum clean all && sudo yum makecache 已加载插件:fastestmirror Repository centos-sclo-rh is listed more than once in the configuration Repository centos-sclo-sclo is listed more than once in the configuration 正在清理软件源: base centos-sclo-rh centos-sclo-sclo docker-ce-stable epel extras updates Cleaning up list of fastest mirrors Other repos take up 1.6 M of disk space (use --verbose for details) 已加载插件:fastestmirror Repository centos-sclo-rh is listed more than once in the configuration Repository centos-sclo-sclo is listed more than once in the configuration Determining fastest mirrors base | 3.6 kB 00:00:00 http://mirror.centos.org/centos/7/sclo/aarch64/rh/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found 正在尝试其它镜像。 To address this issue please refer to the below wiki article https://wiki.centos.org/yum-errors If above article doesn't help to resolve this issue please use https://bugs.centos.org/. One of the configured repositories failed (CentOS-7 - SCLo rh), 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=centos-sclo-rh ... 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 centos-sclo-rh or subscription-manager repos --disable=centos-sclo-rh 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=centos-sclo-rh.skip_if_unavailable=true failure: repodata/repomd.xml from centos-sclo-rh: [Errno 256] No more mirrors to try. http://mirror.centos.org/centos/7/sclo/aarch64/rh/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
07-16
[root@localhost ~]# cat > /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo << 'EOF' > [centos-sclo-rh] > name=CentOS-7 - SCLo rh > baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/ > gpgcheck=0 > enabled=1 > > [centos-sclo-rh-source] > name=CentOS-7 - SCLo rh - Source > baseurl=https://mirrors.aliyun.com/centos/7/sclo/Source/rh/ > gpgcheck=0 > enabled=0 > EOF [root@localhost ~]# yum clean all 已加载插件:fastestmirror 正在清理软件源: base centos-sclo-rh centos-sclo-sclo docker-ce-stable epel extras updates Cleaning up list of fastest mirrors [root@localhost ~]# yum makecache 已加载插件:fastestmirror Determining fastest mirrors 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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo [root@localhost ~]# yum install -y centos-release-scl 已加载插件: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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo [root@localhost ~]# yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils 已加载插件: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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo [root@localhost ~]# sed -i 's/mirrors.aliyun.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo [root@localhost ~]# yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils 已加载插件: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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo [root@localhost ~]# unset http_proxy https_proxy [root@localhost ~]# yum install -y devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils 已加载插件: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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo [root@localhost ~]#
最新发布
12-06
pooot@lavm-9gudogn65e ~]# sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.re % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2523 100 2523 0 0 10688 0 --:--:-- --:--:-- --:--:-- 10736 [root@lavm-9gudogn65e ~]# # 确保$releasever变量正确设置为7 [root@lavm-9gudogn65e ~]# sudo sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo [root@lavm-9gudogn65e ~]# [root@lavm-9gudogn65e ~]# # 验证$basearch变量(通常是x86_64) [root@lavm-9gudogn65e ~]# sudo sed -i 's/\$basearch/x86_64/g' /etc/yum.repos.d/CentOS-Base.repo [root@lavm-9gudogn65e ~]# # 清除所有缓存 [root@lavm-9gudogn65e ~]# sudo yum clean all Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. Cleaning repos: base centos-sclo-rh centos-sclo-sclo epel extras updates [root@lavm-9gudogn65e ~]# [root@lavm-9gudogn65e ~]# # 重建元数据缓存 [root@lavm-9gudogn65e ~]# sudo yum makecache Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager to register. base | 3.6 kB 00:00:00 centos-sclo-rh | 3.0 kB 00:00:00 One of the configured repositories failed (Unknown), 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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-sclo 可以尝试更换源,研究元婴其问题
10-22
(venv) [root@iZ7xverg9iufrkfag7y2yzZ report2]# sudo yum --enablerepo=centos-sclo-sclo search devtoolset | grep gcc 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 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=<repoid> ... 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 <repoid> or subscription-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 much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64 (venv) [root@iZ7xverg9iufrkfag7y2yzZ report2]#
08-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

awei0916

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值