【第一種方式】
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