yum update 报错 Cannot find a valid baseurl for repo: centos-sclo-rh/x86_64 等解决办法

powershell 复制代码
[root@librsmaster zdh]# sudo yum update
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
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

首先备份现有的

cp -r /etc/yum.repos.d /etc/yum.repos.d.backup

cd 到 /etc/yum.repos.d

删掉里面内容

rm -rf CentOS*

然后执行

powershell 复制代码
cat <<EOF > /etc/yum.repos.d/CentOS-SCLo-rh.repo
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF

在添加 注意/是一个

powershell 复制代码
cat <<EOF >  /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/os/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/updates/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/7/extras/$basearch/
gpgcheck=1
enabled=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
EOF

禁用失效的镜像列表

powershell 复制代码
sed -i 's/^mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo

清理并重建缓存

清理 YUM 缓存并重建缓存,以确保系统能够正确使用新的仓库源:

powershell 复制代码
yum clean all
yum makecache

验证一下

powershell 复制代码
yum install -y tree
相关推荐
冲上云霄的Jayden3 分钟前
bash执行脚本 CondaError: Run ‘conda init‘ before ‘conda activate‘
linux·ubuntu·conda·bash·init·activate
闭着眼睛学算法11 分钟前
【双机位A卷】华为OD笔试之【哈希表】双机位A-跳房子I【Py/Java/C++/C/JS/Go六种语言】【欧弟算法】全网注释最详细分类最全的华子OD真题题解
java·c语言·c++·python·算法·华为od·散列表
无限码力16 分钟前
华为OD技术面真题 - Python开发 - 2
python·华为od·华为od技术面真题·华为od技术面八股·华为od技术面python八股·华为od面试python真题·华为odpython八股
驱动探索者26 分钟前
影石Insta360发展史:从深圳公寓到全球影像创新标杆
linux
Wang's Blog35 分钟前
Linux小课堂: SSH 免密登录原理与实现之基于公钥认证的安全连接机制
linux·安全·ssh
戴草帽的大z1 小时前
交叉编译FFmpeg:从x264到RK3588部署实战
linux·ffmpeg·rk3588·h.264·aarch64
qiuiuiu4131 小时前
正点原子RK3568学习日志19- Linux错误处理 字符驱动框架完全体
linux·服务器·学习·ubuntu
如果是君1 小时前
【git使用】ubuntu下利用git工具提交一个工程
linux·git·ubuntu
橘颂TA1 小时前
【Linux】 层层递进,抽丝剥茧:调度队列、命令行参数、环境变量
linux·运维·服务器·c/c++
九皇叔叔2 小时前
Java循环结构全解析:从基础用法到性能优化(含经典案例)
java·开发语言·python