[Centos系统] centos7中安装了centos-release-scl后,之前的yum源变为不可用 解决方案

511 0
Honkers 2025-12-22 16:26:27 来自手机 | 显示全部楼层 |阅读模式

centos7中安装了centos-release-scl后,之前的yum源变为不可用 解决方案

1. 前言

今天遇到了一个奇奇怪怪的事情,我自己在自己的服务器(centos7)上安装了centos-release-scl后,之前运行正常的yum命令竟然变得不可用。

2. 场景重现

执行下面这条命令后,再次使用yum报错。

  1. yum install centos-release-scl -y
复制代码

报错信息如下:

  1. [root@localhost ~]# sudo yum install devtoolset-11
  2. Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
  3. 14: curl#7 - "Failed to connect to 2a05:d012:8b5:6503:9efb:5cad:348f:e826: 网络不可达"
  4. One of the configured repositories failed (未知),
  5. and yum doesn't have enough cached data to continue. At this point the only
  6. safe thing yum can do is fail. There are a few ways to work "fix" this:
  7. 1. Contact the upstream for the repository and get them to fix the problem.
  8. 2. Reconfigure the baseurl/etc. for the repository, to point to a working
  9. upstream. This is most often useful if you are using a newer
  10. distribution release than is supported by the repository (and the
  11. packages for the previous distribution release still work).
  12. 3. Disable the repository, so yum won't use it by default. Yum will then
  13. just ignore the repository until you permanently enable it again or use
  14. --enablerepo for temporary usage:
  15. yum-config-manager --disable <repoid>
  16. 4. Configure the failing repository to be skipped, if it is unavailable.
  17. Note that yum will try to contact the repo. when it runs most commands,
  18. so will have to try and fail each time (and thus. yum will be be much
  19. slower). If it is a very temporary problem though, this is often a nice
  20. compromise:
  21. yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
  22. Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64
复制代码

3. 什么是SCL?

SCL项目主页:https://www.softwarecollections.org/

SCL(Software Collections)可以让你在同一个操作系统上安装和使用多个版本的软件,而不会影响整个系统的安装包。SCL为社区的以下需求而设计:创建和使用软件集合生产系统、概念验证系统、开发测试平台。SCL目前已经支持Fedora和RHEL(衍生版本如CentOS也包含在内)。

SCL的创建就是为了给RHEL/CentOS用户提供一种以方便、安全地安装和使用应用程序和运行时环境的多个(而且可能是更新的)版本的方式,同时避免把系统搞乱。与之相对的是第三方源,它们可能会在已安装的包之间引起冲突。

现在有以下软件选集可供CentOS 6.5或以上版本应用。

  1. Ruby 1.9.3 (ruby193)
  2. Python 2.7 (python27)
  3. Python 3.3 (python33)
  4. PHP 5.4 (php54)
  5. Perl 5.16.3 (perl516)
  6. Node.js 0.10 (nodejs010)
  7. MariaDB 5.5 (mariadb55)
  8. MySQL 5.5 (mysql55)
  9. PostgreSQL 9.2 (postgresql92)
复制代码

更多的软件集可参看这里:https://www.softwarecollections.org/en/scls/。

3.1 安装SCL

在CentOS下访问SCL,需要安装CentOS Software Collections。它是CentOS Extras软件库的一部份,并可通过以下指命进行安装。

  1. Centos 7
  2. $ yum install centos-release-scl
  3. Centos 6
  4. $ yum install centos-release-SCL
  5. 注意:Centos6和Centos7的包名是区分大小写的!
复制代码

4. 问题分析

可能的原因是在安装 centos-release-scl 后,系统软件包管理器 yum 可能遇到了问题。centos-release-scl 是用于安装 Software Collections 的软件包,它提供了一种在 CentOS 系统上安装和管理多个软件版本的方法。

在安装 centos-release-scl 后,可能会导致系统的软件仓库配置发生变化,或者出现与旧有软件包版本冲突的情况。这可能会影响 yum 命令的正常运行,因为它依赖于正确的软件包仓库配置和软件包版本管理。

5. 解决方案

进入/etc/yum.repos.d下查看文件。发现有三个yum配置文件。

  1. cd /etc/yum.reps.d
复制代码
  1. ls
  2. CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-SCLo-scl-rh.repo CentOS-Vault.repo CentOS-CR.repo CentOS-fasttrack.repo CentOS-SCLo-scl.repo CentOS-Sources.repo
复制代码

CentOS-Base.repo / CentOS-SCLo-scl-rh.repo /CentOS-SCLo-scl.repo

需要在这三个文件中配置yum源,但是查看发现CentOS-Base.repo配置了阿里云镜像,因此需要修改其他两个文件。配置yum的镜像源。首先对CentOS-SCLo-scl-rh.repo进行修改。

  1. vi CentOS-SCLo-scl-rh.repo
  2. # 修改后
  3. [centos-sclo-rh]
  4. name=CentOS-7 - SCLo rh
  5. baseurl=http://vault.centos.org/centos/7/sclo/$basearch/rh/
  6. gpgcheck=1
  7. enabled=1
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
复制代码

修改后发现依旧无法使用,将CentOS-SCLo-scl.repoyum源进行修改。

  1. vi CentOS-SCLo-scl.repo
  2. # 修改后
  3. [centos-sclo-sclo]
  4. name=CentOS-7 - SCLo sclo
  5. baseurl=http://vault.centos.org/centos/7/sclo/$basearch/rh/
  6. gpgcheck=1
  7. enabled=1
  8. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
复制代码

修改之后yum即可正常使用。

  1. yum clean all
  2. yum makecache
复制代码

参考文献:https://blog.csdn.net/m0_63303316/article/details/140200199

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行