原因是yum源出问题了,解决方法:直接将linux服务器默认的yum替换成国内镜像的yum源,比如:阿里云yum镜像源
CentOS修改默认yum源为阿里云yum镜像源详细步骤:
1.备份你的原镜像文件,以免出错后可以恢复
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2.下载新的CentOS-Base.repo 到/etc/yum.repos.d
根据版本执行命令:
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
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
3.运行yum makecache生成缓缓存
yum clean all
yum makecache
4.再去运行yum命令就可以正常使用了