更新阿里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

posted @ 2019-10-27 15:27  ritchy  阅读(2481)  评论(0编辑  收藏  举报