配置yum源方法,以及失效时的处理

正常方法如下:

step1:

备份原CentOS-Base.repo 文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak


step2:

wget yum源(网易,阿里等都可以) http://mirrors.163.com/.help/centos.html 选择自己的服务器的版本
wget http://mirrors.163.com/.help/CentOS5-Base-163.repo


step3:
yum clean all
yum makecache 后续没报错最好

如果报错获取不到

我们发现,网易的镜像都已经转移了,可以在 http://mirrors.163.com/centos/5]看到readme文件,内容如下:
This directory (and version of CentOS) is depreciated.

CentOS-5 is now past EOL

You can get the last released version of centos 5.11 here:

http://vault.centos.org/5.11/

Please NOTE: this is not being maintained for security since moving to Vault.
It will have security issues, you should upgrade to a new version instead.
现在的最新镜像是在http://vault.centos.org/这个网址下 
所以我们只需要现在的源文件CentOS5-Base-163.repo,注释掉mirrolist,同时将baseurl的注释打开并将原url替换为http://vault.centos.org即可 。

(2)

修改完成之后还是报404错误,结果是由于 $releasever 的值是5,而我的版本是5.11,所以我直接将变量 $releasever 全局替换为5.11,至此问题解决了. 
可以利用命令
rpm -qi centos-release
查看$releasever的值 

备注:有两个yum源的时候会报错,,关闭失效的yum源即可,如果是contOS6系统还需要修改gpgkey这个后的值为

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

修正后文件代码:

 


最后

yum clean all
yum makecache

 

yum知识点记录:

yum -y update

升级所有包,改变软件设置和系统设置,系统版本内核都升级

yum -y upgrade

升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变

posted @ 2017-05-03 11:32  天边的明月  阅读(3170)  评论(0编辑  收藏  举报