如何更換yum源
linux教程
2022-01-13 06:06
6323
yum,全稱“Yellow dog Updater, Modified”,是一個專門為了解決包的依賴關(guān)系而存在的軟件包管理器。類似于我們軟件管家一樣,一鍵安裝軟件并解決環(huán)境依賴關(guān)系,而且也可以管理并一鍵卸載。
目前僅僅對CentOS7和CentOS8的yum源更換(阿里云源),首先你的服務(wù)器要支持快照,不支持請不要做下面的操作,以免影響你的服務(wù)器正常使用。
寶塔官方解決辦法(我測試沒能解決,但是我執(zhí)行了一遍)
1、備份原來的yum源,
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
centos7:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
centos8:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
更換后執(zhí)行:
yum clean all
清除原來的yum源緩存
然后執(zhí)行
yum makecache
生成新的yum源緩存
阿里云方法
配置方法
1. 備份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下載新的 CentOS-Base.repo 到 /etc/yum.repos.d/
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
3. 運行 'yum makecache '生成緩存
4. 其他
非阿里云ECS用戶會出現(xiàn) Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影響使用。用戶也可自行修改相關(guān)配置: eg:
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo