centos7默认的源的网址mirrorlist.centos.org,属于国外的网站,可能出现连不上或者网速很慢,刚开始我装软件用yum命令基本都装不上,后来经过思考,原来默认yum源设置的问题。阿里yum源是国内最好的yum源之一,无论是速度还是软件版本,都非常的不错,将yum源设置为阿里yum镜像源,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。

1.备份本地系统自带yum源配置文件

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

2.下载阿里yum源配置文件并代替/etc/yum.repos.d/默认的yum源配置文件

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

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

3.生成cache缓存

yum makecache

4.更新yum为最新版本

yum -y update

5.最后你可能还需要同时更新使用阿里epel源

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup

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

yum clean all && yum makecache