更新阿里yum源並重建緩存


【第一種方式】
1、下載安裝wget /如果沒有裝的話
yum install -y wget

2、備份默認的yum
mv /etc/yum.repos.d /etc/yum.repos.d.backup

3、設置新的yum目錄
mkdir /etc/yum.repos.d

4、下載阿里yum配置到該目錄中,選擇對應版本
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
將 https://mirrors.tuna.tsinghua.edu.cn/help/centos/ 中的內容粘貼到 CentOS-Base.repo

5、重建緩存
yum clean all
yum makecache fast

6、升級所有包(改變軟件設置和系統設置,系統版本內核都升級,故需要幾分鍾耐心等待)
yum update -y

【第二種方式】
--腳本
vi yum.sh

#!/bin/bash
mv /etc/yum.repos.d/* /mnt
a=`cat /etc/redhat-release |awk '{print $3}'|awk -F . '{print $1}'`
if [ $a == 6 ];then
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
else
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
fi
yum clean all
yum makecache fast

--授權
chmod 777 yum.sh

--執行
./yum.sh

--升級包
yum update -y

轉自centos 7 部署 漢化版 gitlab
https://www.cnblogs.com/straycats/p/7637373.html


免責聲明!

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



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