CentOS7 更新yum源

备份原来的yum源

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 

设置aliyun的yum源

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 

添加EPEL源

wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo

清理缓存,生成新缓存,执行yum更新

# 清除缓存
yum clean all
# 生成新的缓存
yum makecache

再次运行yum clean all 清除缓存,运行 yum makecache 生成新的缓存

查看启用的yum源和所有的yum源

yum repolist enabled
yum repolist all

更新yum

yum -y update