CentOS 8 換源,設置dnf / yum鏡像


centos 8 默認是會讀取centos.org的mirrorlist的,所以一般來說是不需要配置鏡像的。
如果你的網絡訪問mirrorlist有問題,才需要另外配置
相關鏡像配置,請參考各鏡像站的相關幫助
https://developer.aliyun.com/mirror/
https://mirrors.tuna.tsinghua.edu.cn/help/centos/
http://mirrors.ustc.edu.cn/help/centos.html

dnf fastest mirror

dnf集成了fastest mirror功能,在yum中這是需要單獨安裝插件使用的。
此方法要求你能夠訪問 http://mirrorlist.centos.org
配置后,dnf會自動到mirror list中查找最快的鏡像。

#修改配置
vi /etc/dnf/dnf.conf

fastestmirror=True

#使用
sudo dnf clean all
sudo dnf makecache

aliyun鏡像

aliyun更新了centos8的說明:https://developer.aliyun.com/mirror/centos

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

需要注意的是Base.repo文件中也帶了AppStream,這會提示重復的AppStream。

sed自行修改

cd /etc/yum.repos.d
#備份
cp CentOS-Base.repo CentOS-Base.repo.bak
cp CentOS-AppStream.repo CentOS-AppStream.repo.bak
cp CentOS-Extras.repo CentOS-Extras.repo.bak

sed -i 's|mirrorlist=|#mirrorlist=|g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
sed -i 's|#baseurl=|baseurl=|g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
sed -i 's|http://mirror.centos.org|https://mirrors.aliyun.com|g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo


免責聲明!

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



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