一、Linux 版本
1.RedHat系列:Centos x86_64
2.CPU - 2核 内存 - 2GB
二、Linux 输入 yum 异常报错
[root@VM-8-15-centos ~]# yum update
报异常
Loaded plugins: fastestmirror, langpacks
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
三、原因分析与解决
1.原因
CentOS7的SCL源在2024年6月30日就停止维护了。 当scl源里面默认使用了centos官方的地址http://mirrorlist.centos.org就无法连接,这里我们需要替换为阿里云的默认地址https://mirrors.aliyun.com。
2.解决
(1). 找到 CentOS-SCLo-scl.repo 和 CentOS-SCLo-scl-rh.repo
[root@VM-8-15-centos yum.repos.d]# cd /etc/yum.repos.d/
[root@VM-8-15-centos yum.repos.d]# ll
total 56
-rw-r--r-- 1 root root 2523 Nov 12 14:13 CentOS-Base.repo
-rw-r--r-- 1 root root 614 Nov 12 14:13 CentOS-Base.repo.bak
-rw-r--r-- 1 root root 1309 May 21 22:48 CentOS-CR.repo
-rw-r--r-- 1 root root 649 May 21 22:48 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root 230 Nov 8 15:32 CentOS-Epel.repo
-rw-r--r-- 1 root root 314 Nov 12 14:22 CentOS-fasttrack.repo
-rw-r--r-- 1 root root 630 May 21 22:48 CentOS-Media.repo
-rw-r--r-- 1 root root 1063 Nov 12 14:37 CentOS-SCLo-scl.repo
-rw-r--r-- 1 root root 1034 Nov 12 14:38 CentOS-SCLo-scl-rh.repo
-rw-r--r-- 1 root root 1331 May 21 22:48 CentOS-Sources.repo
-rw-r--r-- 1 root root 9454 May 21 22:48 CentOS-Vault.repo
-rw-r--r-- 1 root root 616 May 21 22:48 CentOS-x86_64-kernel.repo
(2)将里面的 mirrorlist= 注释掉,再将baseurl= 取消注释,并把baseurl的域名地址改为阿里云 https://mirrors.aliyun.com
CentOS-SCLo-scl.repo 文本修改后如下
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
# baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/sclo/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
baseurl=http://mirrors.aliyun.com/centos/7/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-sclo-testing]
name=CentOS-7 - SCLo sclo Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-sclo-debuginfo]
name=CentOS-7 - SCLo sclo Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
CentOS-SCLo-scl-rh.repo 文本修改如下
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
#baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
#mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-rh
baseurl=http://mirrors.aliyun.com/centos/7/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
(3)测试
运行 yum update 就成功了
[root@VM-8-15-centos yum.repos.d]# yum update