正常方法如下:
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
升級所有包,不改變軟件設置和系統設置,系統版本升級,內核不改變