方法一
(适用于无wget的方法,快速但没有镜像加速功能,在使用之前可以测试一下能否ping通该地址)
cd /etc/yum.repos.d/
sed -i ‘s/mirrorlist/#mirrorlist/g’ /etc/yum.repos.d/CentOS-
sed -i ‘s|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g’ /etc/yum.repos.d/CentOS-
yum update
方法二
(适用于有wget且附带镜像加速)
http://mirrors.163.com/.help/centos.html
1)备份源文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2)下载对应文件到/etc/yum.repos.d下
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
安装epel.repo源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
3)生成缓存
yum clean all yum makecache