https://mirrors.sohu.com/fedora/releases/$releasever/Everything/i386/os/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Repository updates is listed more than once in the configuration
兩大問題:
updates, fedora 等出現多次)cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup/
# CentOS 7 (最常見)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/CentOS-7.repo
# CentOS 8 / Stream
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/CentOS-8.repo
# 或使用清華源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.tuna.tsinghua.edu.cn/help/centos/
yum clean all
yum makecache
編輯 /etc/yum.repos.d/CentOS-Base.repo,將 mirrorlist 註釋,baseurl 指向鏡像:
[base]
name=CentOS-$releasever - Base
# mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=https://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
檢查 /etc/yum.repos.d/ 下所有 .repo 檔案,刪除重複定義的區段:
# 查看所有 repo 定義
grep -r "^\[" /etc/yum.repos.d/
# 刪除多餘檔案 (如 fedora.repo, updates.repo 等非 CentOS 官方檔案)
rm -f /etc/yum.repos.d/fedora.repo /etc/yum.repos.d/updates.repo
| 鏡像站 | CentOS 7 Base URL | 適用版本 |
|---|---|---|
| 阿里雲 | https://mirrors.aliyun.com/centos/ | CentOS 7/8/Stream |
| 清華大學 | https://mirrors.tuna.tsinghua.edu.cn/centos/ | CentOS 7/8/Stream |
| 中科大 | https://mirrors.ustc.edu.cn/centos/ | CentOS 7/8/Stream |
| 網易 | https://mirrors.163.com/centos/ | CentOS 7/8 |
| 騰訊雲 | https://mirrors.cloud.tencent.com/centos/ | CentOS 7/8/Stream |
# 安裝 EPEL
yum install -y epel-release
# 替換為阿里雲 EPEL
sed -i 's|^metalink=|#metalink=|g' /etc/yum.repos.d/epel.repo
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub/epel|baseurl=https://mirrors.aliyun.com/epel|g' /etc/yum.repos.d/epel.repo
yum repolist all
yum install -y vim wget net-tools # 測試安裝常用工具