安裝 git 時,突然報以下錯誤;提示
爲 repo ‘epel-modular’ 下載元數據失敗
錯誤:爲 repo ‘epel-modular’ 下載元數據失敗
如圖所示
解決方案:
修改鏡像源爲阿里雲鏡像源
step 1 vi /etc/yum.repos.d/CentOS-Base.repo
修改爲如下內容
[BaseOS]
name=CentOS-$releasever - Base
release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
step 2 vi /etc/yum.repos.d/CentOS-AppStream.repo
修改爲如下內容
[AppStream]
name=CentOS-$releasever - AppStream
release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
step 3 重建緩存
# 清除所有緩存文件
dnf clean all
# 製作元數據緩存
dnf mackecache
經過以上步驟,再次安裝 git
執行成功