当前系统为 CentOS 8.5.
[root@localhost ~]# cat /etc/centos-release
CentOS Linux release 8.5.2111
在使用 yum 安装软件时,报错如下:
[root@localhost ~]# yum install *expect*
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Base.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Base.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Base.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Base.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Base.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS-8 - Base - mirrors.aliyun.com 57 B/s | 2.3 kB 00:40
Errors during downloading metadata for repository 'base':
- Status code: 404 for https://mirrors.aliyun.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 119.41.210.238)
- Curl error (28): Timeout was reached for http://mirrors.aliyuncs.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml [Connection timed out after 30000 milliseconds]
- Curl error (6): Couldn't resolve host name for http://mirrors.cloud.aliyuncs.com/centos/8/BaseOS/x86_64/os/repodata/repomd.xml [Could not resolve host: mirrors.cloud.aliyuncs.com]
Error: Failed to download metadata for repo 'base': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
解决办法:
- 首先备份原有数据
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo1
cp /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-AppStream.repo1
- 编辑如下文件,意在进行字符串替换:
vim /etc/yum.repos.d/CentOS-Base.repo
# 在 vim 命令模式下执行:(不包含引号)
":%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g"
# 继续执行:
":%s/$releasever/$releasever-stream/g"
vim /etc/yum.repos.d/CentOS-AppStream.repo
# 在 vim 命令模式下执行:(不包含引号)
":%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g"
# 继续执行:
":%s/$releasever/$releasever-stream/g"
- 执行命令行
yum makecache
yum update
- yum命令执行效果
[root@localhost yum.repos.d]# yum update
Last metadata expiration check: 0:00:24 ago on Tue 22 Feb 2022 08:04:41 PM CST.
Error:
Problem: package centos-stream-release-8.6-1.el8.noarch requires centos-stream-repos, but none of the providers can be installed
- package centos-linux-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-2.el8.noarch
- package centos-stream-repos-8-2.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-3.el8.noarch
- package centos-linux-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-3.el8.noarch
- package centos-stream-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-3.el8.noarch
- package centos-linux-repos-8-3.el8.noarch conflicts with centos-repos(8) provided by centos-stream-repos-8-4.el8.noarch
- package centos-stream-repos-8-4.el8.noarch conflicts with centos-repos(8) provided by centos-linux-repos-8-3.el8.noarch
- cannot install the best update candidate for package centos-linux-release-8.5-1.2111.el8.noarch
- problem with installed package centos-linux-repos-8-3.el8.noarch
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# yum install *expect*
Last metadata expiration check: 0:00:49 ago on Tue 22 Feb 2022 08:04:41 PM CST.
Package python3-pexpect-4.3.1-3.el8.noarch is already installed.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing:
expect x86_64 5.45.4-5.el8 base 267 k
Installing dependencies:
tcl x86_64 1:8.6.8-2.el8 base 1.1 M
Transaction Summary
===================================================================================================================================================================================================================
Install 2 Packages
Total download size: 1.4 M
Installed size: 4.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): expect-5.45.4-5.el8.x86_64.rpm 50 kB/s | 267 kB 00:05
(2/2): tcl-8.6.8-2.el8.x86_64.rpm 212 kB/s | 1.1 MB 00:05
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 262 kB/s | 1.4 MB 00:05
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : tcl-1:8.6.8-2.el8.x86_64 1/2
Running scriptlet: tcl-1:8.6.8-2.el8.x86_64 1/2
Installing : expect-5.45.4-5.el8.x86_64 2/2
Running scriptlet: expect-5.45.4-5.el8.x86_64 2/2
Verifying : expect-5.45.4-5.el8.x86_64 1/2
Verifying : tcl-1:8.6.8-2.el8.x86_64 2/2
Installed:
expect-5.45.4-5.el8.x86_64 tcl-1:8.6.8-2.el8.x86_64
Complete!
[root@localhost yum.repos.d]#
注意:实际使用中如果没有 CentOS-AppStream.repo, 则不对其进行操作。