CentOS7系统使用yum命令报错:Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64

报错信息:

[root@iZwz946ibli8ikuyqgtc58Z ~]# yum install rh-redis5-redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
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

出错原因: 上述错误信息表明无法检索镜像列表,原因是 http://mirrorlist.centos.org 已经停止服务了,因此我们需要更改scl源的baseUrl。

解决方案:
1、进入/etc/yum.repos.d目录,删除目录下面所有的软件包,删除命令如下:

sudo rm -rf *


2、下载安装阿里云镜像仓库:两条命令都行

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo


3、下载安装阿里云epel.repo:

sudo curl -o /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo

sudo wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo


4、清除缓存:

yum clean all 


5、生成缓存:

yum makecache



6、安装gcc-c++测试:

sudo yum -y install gcc-c++



                        

### 解决 Zabbix 安装过程中 CentOS 仓库报错问题 在安装 Zabbix 的过程中,如果遇到类似 `Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64` 的错误,通常是由于 CentOS 仓库配置文件中的镜像列表不可用或网络连接问题导致的。以下是详细的解决方案: #### 1. 镜像列表不可用的原因 CentOS 的 `mirrorlist` 文件可能由于以下原因无法正常工作: - 镜像列表服务器不可用。 - 系统架构与仓库配置不匹配。 - 网络 DNS 配置错误。 #### 2. 修改仓库配置文件 可以通过编辑 CentOSYum 配置文件来解决此问题。例如,对于 `centos-sclo-rh` 仓库,可以手动指定一个稳定的镜像源。以下是修改后的配置文件示例: ```ini [centos-sclo-rh] name=CentOS-7 - SCLo rh baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/ # 替换为阿里云镜像源[^1] gpgcheck=1 enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo ``` #### 3. 清理缓存并更新仓库 清理 Yum 缓存并重新加载仓库以确保配置生效: ```bash yum clean all yum makecache ``` #### 4. 安装 Zabbix 相关组件 在完成上述配置后,重新执行 Zabbix 的安装命令: ```bash yum install -y centos-release-scl # 安装 SCL 扩展包[^1] yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl # 示例:安装 Zabbix 相关组件 ``` #### 5. 替代镜像源 如果默认的 CentOS 镜像源仍然不可用,可以尝试以下替代镜像源: - **阿里云**:`https://mirrors.aliyun.com/centos/$releasever/os/$basearch/` - **腾讯云**:`https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/` - **华为云**:`https://repo.huaweicloud.com/centos/$releasever/os/$basearch/` 将这些镜像源替换到对应的仓库配置文件中即可。 #### 6. 检查系统架构和版本 确保 `$basearch` 和 `$releasever` 的值正确无误。可以通过以下命令确认: ```bash uname -m # 检查系统架构,通常为 x86_64 cat /etc/redhat-release # 检查 CentOS 版本 ``` --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值