将yum源更换为国内的阿里云源

https://yq.aliyun.com/articles/33286 http://mirrors.aliyun.com/repo/

1)、备份原镜像文件以备不时之需

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2)、从http://mirrors.aliyun.com/repo/选择合适的CentOS-Base.repo,并下载到/etc/yum.repos.d/文件夹,如centos7:

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

更改CentOS-Media.repo使其为不生效:

enabled=0

3)、运行yum makecache生成缓存

yum clean all
yum makecache