鉴于国外的yum源经常连不上,切换成国内的yum源,我们首选阿里的,也可以是腾讯云的
备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
之后运行yum makecache生成缓存
yum clean all
yum makecache
腾讯云的话:
[extras] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/extras/$basearch/ name=Qcloud centos extras - $basearch [os] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/os/$basearch/ name=Qcloud centos os - $basearch [updates] gpgcheck=1 gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-7 enabled=1 baseurl=http://mirrors.tencentyun.com/centos/$releasever/updates/$basearch/ name=Qcloud centos updates - $basearch