1、安装wget,用于下载资源
yum install wget
2、更换yum源。现在默认是是国外源,速度很慢,甚至有些根本无法下载(可能是墙)
2.1更换为阿里云(先备份)
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2.2添加EPEL
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
重构
yum clean all
yum makecache
我的重构这一步出问题了:Failed connect to mirrors.aliyuncs.com:80; Connection refused
解决办法:替换CentOS-Base.repo文件$releasever变量为相关linux版本,这里替换为“7”就可以了
vi /etc/yum.repos.d/CentOS-Base.repo
:%s/$releasever/7/ge
:wq
在重新执行重构yum的cache
yum clean all
yum makecache
正常了