yum安裝軟件報錯:Invalid configuration value: failovermethod=priority...

鏡像下載贤壁、域名解析、時間同步請點擊 阿里云開源鏡像站

錯誤一:

Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Linux-BaseOS.repo; Configuration: OptionBinding with id "failovermethod" does not exist
CentOS Linux 8 - AppStream                                                 6.3 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'appstream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: 100.100.2.148)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

當前環(huán)境為:

[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# uname -srm
Linux 4.18.0-348.2.1.el8_5.x86_64 x86_64

CentOS版本為:

[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 8.5.2111

解決辦法:

1.找到CentOS相關目錄,備份CentOS-AppStream,CentOS-Base文件,一般CentOS目錄在/etc/yum.repos.d文件夾下,如下:

file

備份:

cp CentOS-Linux-AppStream.repo CentOS-Linux-AppStream.repo1
cp CentOS-Linux-BaseOS.repo CentOS-Linux-BaseOS.repo1

2.編輯文件CentOS-Linux-AppStream.repo,CentOS-Linux-BaseOS.repo進行字符串替換:

vi CentOS-Linux-BaseOS.repo
# esc 鍵盤 : 命令模式下執(zhí)行:
%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g 
# 繼續(xù)執(zhí)行:
%s/$releasever/$releasever-stream/g
 
vi CentOS-Linux-AppStream.repo
# esc 鍵盤 : 命令模式下執(zhí)行:
%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g 
# 繼續(xù)執(zhí)行:
%s/$releasever/$releasever-stream/g

3.執(zhí)行命令:

yum makecache
yum update

命令執(zhí)行效果:

[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# yum update
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Linux-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Last metadata expiration check: 0:01:22 ago on Wed 09 Mar 2022 10:20:01 AM 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)

再次執(zhí)行命令yum install expect,結果如下:

[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# yum install *expect*
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Linux-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Last metadata expiration check: 0:07:00 ago on Wed 09 Mar 2022 10:20:01 AM 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                baseos               267 k
 python3-aexpect               noarch               1.6.2-1.el8                 epel                  93 k
Installing dependencies:
 tcl                           x86_64               1:8.6.8-2.el8               baseos               1.1 M
 
Transaction Summary
===========================================================================================================
Install  3 Packages
 
Total download size: 1.5 M
Installed size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): python3-aexpect-1.6.2-1.el8.noarch.rpm                              467 kB/s |  93 kB     00:00    
(2/3): expect-5.45.4-5.el8.x86_64.rpm                                      282 kB/s | 267 kB     00:00    
(3/3): tcl-8.6.8-2.el8.x86_64.rpm                                          351 kB/s | 1.1 MB     00:03    
-----------------------------------------------------------------------------------------------------------
Total                                                                      461 kB/s | 1.5 MB     00:03     
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/3 
  Running scriptlet: tcl-1:8.6.8-2.el8.x86_64                                                          1/3 
  Installing       : expect-5.45.4-5.el8.x86_64                                                        2/3 
  Installing       : python3-aexpect-1.6.2-1.el8.noarch                                                3/3 
  Running scriptlet: python3-aexpect-1.6.2-1.el8.noarch                                                3/3 
  Verifying        : expect-5.45.4-5.el8.x86_64                                                        1/3 
  Verifying        : tcl-1:8.6.8-2.el8.x86_64                                                          2/3 
  Verifying        : python3-aexpect-1.6.2-1.el8.noarch                                                3/3 
 
Installed:
  expect-5.45.4-5.el8.x86_64       python3-aexpect-1.6.2-1.el8.noarch       tcl-1:8.6.8-2.el8.x86_64      
 
Complete!

oK,可以進行yum安裝啦.

注意:實際使用中如果沒有 CentOS-AppStream.repo相關文件创泄, 則不對其進行操作

eg:安裝git:

[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# yum -y install git
Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Linux-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Last metadata expiration check: 0:07:51 ago on Wed 09 Mar 2022 10:20:01 AM CST.
Dependencies resolved.
===========================================================================================================
 Package                      Architecture       Version                       Repository             Size
===========================================================================================================
Installing:
 git                          x86_64             2.31.1-2.el8                  appstream             161 k
Installing dependencies:
 git-core                     x86_64             2.31.1-2.el8                  appstream             4.7 M
 git-core-doc                 noarch             2.31.1-2.el8                  appstream             2.6 M
 perl-Error                   noarch             1:0.17025-2.el8               appstream              46 k
 perl-Git                     noarch             2.31.1-2.el8                  appstream              78 k
 perl-TermReadKey             x86_64             2.37-7.el8                    appstream              40 k
 
Transaction Summary
===========================================================================================================
Install  6 Packages
 
Total download size: 7.7 M
Installed size: 38 M
Downloading Packages:
(1/6): git-2.31.1-2.el8.x86_64.rpm                                         299 kB/s | 161 kB     00:00    
(2/6): perl-Error-0.17025-2.el8.noarch.rpm                                 185 kB/s |  46 kB     00:00    
(3/6): perl-Git-2.31.1-2.el8.noarch.rpm                                    290 kB/s |  78 kB     00:00    
(4/6): perl-TermReadKey-2.37-7.el8.x86_64.rpm                              148 kB/s |  40 kB     00:00    
(5/6): git-core-doc-2.31.1-2.el8.noarch.rpm                                385 kB/s | 2.6 MB     00:07    
(6/6): git-core-2.31.1-2.el8.x86_64.rpm                                    394 kB/s | 4.7 MB     00:12    
-----------------------------------------------------------------------------------------------------------
Total                                                                      640 kB/s | 7.7 MB     00:12     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                   1/1 
  Installing       : git-core-2.31.1-2.el8.x86_64                                                      1/6 
  Installing       : git-core-doc-2.31.1-2.el8.noarch                                                  2/6 
  Installing       : perl-TermReadKey-2.37-7.el8.x86_64                                                3/6 
  Installing       : perl-Error-1:0.17025-2.el8.noarch                                                 4/6 
  Installing       : perl-Git-2.31.1-2.el8.noarch                                                      5/6 
  Installing       : git-2.31.1-2.el8.x86_64                                                           6/6 
  Running scriptlet: git-2.31.1-2.el8.x86_64                                                           6/6 
  Verifying        : git-2.31.1-2.el8.x86_64                                                           1/6 
  Verifying        : git-core-2.31.1-2.el8.x86_64                                                      2/6 
  Verifying        : git-core-doc-2.31.1-2.el8.noarch                                                  3/6 
  Verifying        : perl-Error-1:0.17025-2.el8.noarch                                                 4/6 
  Verifying        : perl-Git-2.31.1-2.el8.noarch                                                      5/6 
  Verifying        : perl-TermReadKey-2.37-7.el8.x86_64                                                6/6 
 
Installed:
  git-2.31.1-2.el8.x86_64             git-core-2.31.1-2.el8.x86_64   git-core-doc-2.31.1-2.el8.noarch    
  perl-Error-1:0.17025-2.el8.noarch   perl-Git-2.31.1-2.el8.noarch   perl-TermReadKey-2.37-7.el8.x86_64  
 
Complete!
[root@iZ2vc5xk901ftf2vfscwc1Z yum.repos.d]# git --version
git version 2.31.1

錯誤二:

Invalid configuration value: failovermethod=priority in /etc/yum.repos.d/CentOS-Linux-epel.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Repository extras is listed more than once in the configuration
CentOS Linux 8 - AppStream                                                 6.7 kB/s | 2.3 kB     00:00    
Errors during downloading metadata for repository 'appstream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: xxx.xxx.xxx.xxx)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

解決方法

進入文件 /etc/yum.repos.d/CentOS-Epel.repo,將 failovermethod=priority 注釋:

file

ok, 這樣也可以進行yum安裝

錯誤三:

Errors during downloading metadata for repository 'appstream':
  - Status code: 404 for http://mirrors.cloud.aliyuncs.com/centos/8/AppStream/x86_64/os/repodata/repomd.xml (IP: xxx.xxx.xxx.xxx)
Error: Failed to download metadata for repo 'appstream': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried

這個錯誤的意思是: 為倉庫 'base' 下載元數據失敗

那么我們就要考慮是不是yum源的問題了,因為上面說了,我們的系統(tǒng)是CentOS Linux release 8.5.2111版本的,而CentOS 8操作系統(tǒng)版本結束了生命周期(EOL),Linux社區(qū)已不再維護該操作系統(tǒng)版本

背景信息

2021年12月31日CentOS 8 EOL抑淫。按照社區(qū)規(guī)則,CentOS 8的源地址http://mirror.centos.org/centos/8/內容已移除姥闪,目前第三方的鏡像站中均已移除CentOS 8的源始苇。阿里云的源http://mirrors.cloud.aliyuncs.comhttp://mirrors.aliyun.com也無法同步到CentOS 8的源。當您在阿里云上繼續(xù)使用默認配置的CentOS 8的源會發(fā)生報錯筐喳。報錯示例如下圖所示:

file

您可以通過下文的操作步驟催式,在CentOS 8操作系統(tǒng)的ECS實例中將源配置按照網絡環(huán)境不同進行切換。

yum源:專有網絡VPC類型實例需切換為http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111源疏唾。

epel源:專有網絡VPC類型實例需切換為http://mirrors.cloud.aliyuncs.com/epel-archive/8/

官方操作布置,如下:

1.登錄CentOS 8系統(tǒng)的ECS實例

2.運行以下命令備份之前的repo文件蓄氧。

rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo

3.運行以下命令下載最新的repo文件。

wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo

4.運行以下命令替換repo文件中的鏈接槐脏。

sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g'  /etc/yum.repos.d/Centos-vault-8.5.2111.repo &&  sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo

5.運行以下命令重新創(chuàng)建緩存喉童。

yum clean all && yum makecache

yum源和epel源切換完成后,即可使用yum install命令在實例上安裝您所需要的軟件包

跟著官方的步驟走下去,最后如果有報錯堂氯,下面是正確解決流程:

1.進入/etc/yum.d.repos.d/,運行以下命令備份之前的repo文件

rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo

2.運行以下命令下載最新的repo文件:

wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo

3.運行以下命令替換repo文件中的鏈接蔑担,這一步出錯了,官方提供的命令:

sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo

http://mirrors.cloud.aliyuncs.com 需要替換為http://mirrors.aliyun.com ,但是官方提供的命令沒替換完咽白,如果有執(zhí)行官方提供的命令還是不行的話執(zhí)行下面的命令:

sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g' /etc/yum.repos.d/epel-archive-8.repo

運行以下命令重新創(chuàng)建緩存

yum clean all && yum makecache

執(zhí)行成果啤握,yum install也就可以正常使用了~

本文轉自:https://blog.csdn.net/zhoupenghui168/article/details/123370719

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市晶框,隨后出現(xiàn)的幾起案子排抬,更是在濱河造成了極大的恐慌,老刑警劉巖授段,帶你破解...
    沈念sama閱讀 217,509評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蹲蒲,死亡現(xiàn)場離奇詭異,居然都是意外死亡侵贵,警方通過查閱死者的電腦和手機届搁,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,806評論 3 394
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來窍育,“玉大人卡睦,你說我怎么就攤上這事∈ィ” “怎么了表锻?”我有些...
    開封第一講書人閱讀 163,875評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長辽旋。 經常有香客問我浩嫌,道長,這世上最難降的妖魔是什么补胚? 我笑而不...
    開封第一講書人閱讀 58,441評論 1 293
  • 正文 為了忘掉前任码耐,我火速辦了婚禮,結果婚禮上溶其,老公的妹妹穿的比我還像新娘骚腥。我一直安慰自己,他們只是感情好瓶逃,可當我...
    茶點故事閱讀 67,488評論 6 392
  • 文/花漫 我一把揭開白布束铭。 她就那樣靜靜地躺著,像睡著了一般厢绝。 火紅的嫁衣襯著肌膚如雪契沫。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,365評論 1 302
  • 那天昔汉,我揣著相機與錄音懈万,去河邊找鬼。 笑死,一個胖子當著我的面吹牛会通,可吹牛的內容都是我干的口予。 我是一名探鬼主播,決...
    沈念sama閱讀 40,190評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼涕侈,長吁一口氣:“原來是場噩夢啊……” “哼沪停!你這毒婦竟也來了?” 一聲冷哼從身側響起裳涛,我...
    開封第一講書人閱讀 39,062評論 0 276
  • 序言:老撾萬榮一對情侶失蹤木张,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后调违,有當地人在樹林里發(fā)現(xiàn)了一具尸體窟哺,經...
    沈念sama閱讀 45,500評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 37,706評論 3 335
  • 正文 我和宋清朗相戀三年技肩,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片浮声。...
    茶點故事閱讀 39,834評論 1 347
  • 序言:一個原本活蹦亂跳的男人離奇死亡虚婿,死狀恐怖,靈堂內的尸體忽然破棺而出泳挥,到底是詐尸還是另有隱情然痊,我是刑警寧澤,帶...
    沈念sama閱讀 35,559評論 5 345
  • 正文 年R本政府宣布屉符,位于F島的核電站剧浸,受9級特大地震影響,放射性物質發(fā)生泄漏矗钟。R本人自食惡果不足惜唆香,卻給世界環(huán)境...
    茶點故事閱讀 41,167評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望吨艇。 院中可真熱鬧躬它,春花似錦、人聲如沸东涡。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,779評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽疮跑。三九已至组贺,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間祖娘,已是汗流浹背失尖。 一陣腳步聲響...
    開封第一講書人閱讀 32,912評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人雹仿。 一個月前我還...
    沈念sama閱讀 47,958評論 2 370
  • 正文 我出身青樓增热,卻偏偏與公主長得像,于是被迫代替她去往敵國和親胧辽。 傳聞我的和親對象是個殘疾皇子峻仇,可洞房花燭夜當晚...
    茶點故事閱讀 44,779評論 2 354

推薦閱讀更多精彩內容