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