Linux使用CentOS 7內(nèi)核修改鏡像源解決“Could not resolve host: mirrorlist.centos.org;未知的錯(cuò)誤“問(wèn)題
更新時(shí)間:2025年07月17日 17:22:37 作者:努力的雅木茶
解決yum安裝問(wèn)題需檢查網(wǎng)絡(luò)、備份配置、下載新源、生成緩存及更新源,以恢復(fù)正常使用
解決yum安裝工具時(shí)提示以下錯(cuò)誤信息
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的錯(cuò)誤"
One of the configured repositories failed (未知),
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: base/7/x86_64
1、首先確保虛擬機(jī)網(wǎng)絡(luò)暢通

2、備份系統(tǒng)自帶yum源配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.back
3、通過(guò)curl下載yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

4、運(yùn)行yum makecache生成緩存
yum makecache

5、更新yum源,等待完成即可使用yum下載命令
yum -y update

總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Linux信號(hào)機(jī)制之信號(hào)的保存與處理技巧分享
本文旨在為廣大Linux學(xué)習(xí)者提供一份詳盡而實(shí)用的指南,幫助他們深入理解Linux中的信號(hào)機(jī)制,掌握信號(hào)的保存與處理技巧,我們將從信號(hào)的基本概念出發(fā),逐步深入到信號(hào)的捕獲、保存、處理以及恢復(fù)等各個(gè)環(huán)節(jié),通過(guò)生動(dòng)的實(shí)例和詳細(xì)的解釋,讓讀者能夠輕松掌握2024-10-10
詳解CentOS的SVN服務(wù)器搭建與自動(dòng)部署全過(guò)程
最近因?yàn)楣ぷ餍枰艘粋€(gè)晚上時(shí)間折騰svn,網(wǎng)上的教程太亂太雜,還有很多是錯(cuò)誤的,終于搞定了,所以想著把過(guò)程記錄下來(lái)。這篇文章主要介紹了CentOS的SVN服務(wù)器搭建與自動(dòng)部署全過(guò)程,需要的朋友可以參考借鑒,下面來(lái)一起看看吧。2017-02-02
Ubuntu搭建web站點(diǎn)并發(fā)布公網(wǎng)訪問(wèn)詳細(xì)步驟(內(nèi)網(wǎng)穿透)
這篇文章主要給大家介紹了關(guān)于Ubuntu搭建web站點(diǎn)并發(fā)布公網(wǎng)訪問(wèn)(內(nèi)網(wǎng)穿透)的相關(guān)資料,內(nèi)網(wǎng)穿透是一種實(shí)現(xiàn)在外網(wǎng)任意地點(diǎn)訪問(wèn)內(nèi)網(wǎng)的方法,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-12-12
基于Centos7 部署Varnish緩存代理服務(wù)器
這篇文章主要介紹了基于Centos7 部署Varnish緩存代理服務(wù)器,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01
centos8 使用yum 安裝 mongodb 4.2的方法
這篇文章主要介紹了centos8 使用yum 安裝 mongodb 4.2的方法,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10
Linux判斷系統(tǒng)是否發(fā)生過(guò)異常斷電的三種方法
在Linux(Ubuntu)系統(tǒng)中,判斷系統(tǒng)是否發(fā)生過(guò)異常斷電(非正常關(guān)機(jī)),主要有三種方法,其中方法一是最準(zhǔn)確的,因?yàn)樗昧讼到y(tǒng)的正常關(guān)機(jī)標(biāo)記機(jī)制,下面小編為大家詳細(xì)說(shuō)說(shuō)2026-02-02
linux平臺(tái)的office文檔轉(zhuǎn)pdf的實(shí)例(程序員的菜)
下面小編就為大家?guī)?lái)一篇linux平臺(tái)的office文檔轉(zhuǎn)pdf的實(shí)例(程序員的菜)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-11-11

