1. 程式人生 > 其它 >【轉載】完美解決CentOS8 yum安裝AppStream報錯,更新yum後無法makecache的問題

【轉載】完美解決CentOS8 yum安裝AppStream報錯,更新yum後無法makecache的問題

問題

CentOS 8 yum安裝軟體時,提示無法從AppStream下載

[root@C8-3 ~]# yum -y install httpd mariadb-server mariadb php php-mysql
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository fasttrack is listed more than once in the configuration
CentOS-8 - AppStream                           0.0  B/s |   0  B     00:08    
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

  

更換國內yum源

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

 

清理之前的yum快取

# yum clean all

  

建立新的快取

# yum makecache

  

解決makecahe報錯

centos8會出現以下報錯

CentOS-8 - AppStream                           0.0  B/s |   0  B     00:04    
Failed to download metadata for repo 'AppStream'
Error: Failed to download metadata for repo 'AppStream'

  

解決辦法

  • 將CentOS-AppStream.repo檔案中的連結更新
# vim /etc/yum.repos.d/CentOS-AppStream.repo
  • 註釋掉原有內容,並插入新內容
#這一段註釋掉
#[AppStream] #name=CentOS-$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/ #mirrorlist=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/ #gpgcheck=1 #enabled=1 #pgkey=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=0 gpgcheck=1 gpgkey=http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-Official
  • 重新執行 # yum makecache
# yum makecache