CentOS8 yum install 報錯Cannot prepare internal mirrorlist: No URLs in mirrorlist解決(替換yum源)


  yum install openssl失敗了,加 --releasever=8參數也失敗了

打開/etc/

 

打開看下

 先備份下

mv ./CentOS-Linux-BaseOS.repo ./CentOS-Linux-BaseOS.repo.bak

然后執行

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos8_base.repo

 清空一下yum緩存

 yum clean all

 然后重建yum緩存

yum makecache

 可以看到,又失敗了

我們在替換yum源的時候,按照鏡像網站的操作方式,只替換了CentOS-Base.repo。
可是在CentOS8中,CentOS-Linux-AppStream.repo的內容沒有更新

最好先備份下,我這邊直接修改了

vi ./CentOS-Linux-AppStream.repo 
# CentOS-Linux-AppStream.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are geographically
# close to the client.  You should use this for CentOS updates unless you are
# manually picking other mirrors.
#
# If the mirrorlist does not work for you, you can try the commented out
# baseurl line instead.

#[appstream]
#name=CentOS Linux $releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

[appstream]
name=Qcloud centos AppStream - $basearch
baseurl=http://mirrors.cloud.tencent.com/centos/$releasever/AppStream/$basearch/os/
enabled=1
gpgcheck=1
gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
~                                                                                                                                                                                                                              
~                                                                       

將原來的[appstream]注釋掉,然后修改,wq保存

然后再執行重建yum緩存

yum makecache

 可以看到,源數據緩存已經建立

接下來繼續執行yum install即可

 可以看到,已經執行成功了

也可以將CentOS-Linux-AppStream.repo刪除,不推薦,注意有的版本叫CentOS-Base.repo和CentOS-AppStream.repo

還有[appstream]有的版本是大寫[AppStream]

另附兩個源地址

阿里yum源: https://developer.aliyun.com/mirror/centos
騰迅yum源: https://mirrors.tencent.com/help/centos.html

至此問題解決

如果還不行可以查看下網卡配置里的DNS可以先配置為8.8.8.8試一下,或者修改/etc/resolv.conf里的nameserver為8.8.8.8


再不行就是網絡受限了,加代理或者解決網絡問題

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM