将Centos 的默认yum源改为阿里云的yum源后出现的问题

阿里各版本yum源如下:

  Centos5:http://mirrors.aliyun.com/repo/Centos-5.repo

  Centos6:http://mirrors.aliyun.com/repo/Centos-6.repo

  Centos7:http://mirrors.aliyun.com/repo/Centos-7.repo

操作分为2步

1)、备份原有的yum源,以防发生错误。

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

2)、下载阿里的yum源到/ect/yum.repos.d/下

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

之后运行了一把,yum clean all   。之后yum就报错了,无法安装任何东西,也无法连接网络,ping baidu.com 发现无法ping通 ,ifconfig  发现是dns出了问题。

修改dns :

vi /etc/resolv.conf

添加规则
nameserver 114.114.114.114

然后service network restart 重启网络服务

查看yum状态 yum repolist

生成缓存

yum makecache

可以正常yum了

猜你喜欢

转载自www.cnblogs.com/hyblogs/p/10435185.html