1、下载wget工具
yum install –y wget
2、进入yum源配置文件所在文件夹
cd /etc/yum.repos.d/
3、备份本地yum源
mv CentOS-Base.repo CentOS-Base.repo_bak
4、获取国内yum源(阿里、163二选一)
阿里云:
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
163:
wget -O CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
5、清理缓存、重建缓存、升级Linux系统
清理yum缓存:
yum clean all
重建缓存:
yum makecache
升级Linux系统:
yum -y update
问题:
如 yum makecache 时,报如下错误,将 CentOS-Base.repo 中的 $releasever
变量都替换为 7 即可
vim CentOS-Base.repo
# 在命令模式下,输入以下命令提交替换
:%s/$releasever/7/g