CentOS6.9中使用yum install时提示:Cannot find a valid baseurl for repo: centos-sclo-rh

场景

CentOS的版本为6.9,在使用yum install 安装相关依赖时提示:

Cannot find a valid baseurl for repo: centos-sclo-rh

 

CentOS6.9中使用yum install时提示:Cannot find a valid baseurl for repo: centos-sclo-rh_第1张图片

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

原因是官方结束了对CentOS6的支持,导致在使用yum安装或更新程序的时候出现错误。

首先清空CenOS-Base.repo文件

echo > /etc/yum.repos.d/CentOS-Base.repo

然后编辑该文件

vi /etc/yum.repos.d/CentOS-Base.repo

然后按键盘上的i键进入编辑模式,将下面的内容复制进去

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://#mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=https://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

然后按Esc退出编辑模式,再输入

:wq!

保存并退出

然后删除掉/etc/yum.repos.d/目录下其他无关的repo文件

cd /etc/yum.repos.d/
ls | grep -v 'CentOS-Base.repo' | xargsrm

然后重建yum缓存,更新并启动新的yum源

yum clean all && yummakecache

此时需要等待一段时间,不要按回车。

 

CentOS6.9中使用yum install时提示:Cannot find a valid baseurl for repo: centos-sclo-rh_第2张图片

你可能感兴趣的:(Linux,centos)