centos6.7 yum换源

CentOS6.7 yum源更换为aliyun的源

1.备份原有的CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2.下载aliyun源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
3.若报错
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
4.则执行替换操作
sed -i 's/\$releasever/6/' CentOS-Base.repo
5.清除缓存
yum clean all
6.新增yum缓存
yum makecache
7.若报错
[Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.aliyuncs.com'"
8.新增DNS
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DNS2=8.8.8.8
9.重启网络服务
service network restart
10.重新增缓存
yum clean all && yum makecache

你可能感兴趣的:(linux)