更换软件源:
#cd /etc/yum.repos.d
[root@localhost yum.repos.d]#mv CentOS-Base.repo CentOS-Base.repo.save
[root@localhost yum.repos.d]#wget
[root@localhost yum.repos.d]#mv CentOS-Base.repo.5 CentOS-Base.repo
最好的源:
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base
baseurl=
gpgcheck=1
gpgkey=
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=
gpgcheck=1
gpgkey=
#packages used/produced in the build but not released
[addons]
name=CentOS-$releasever - Addons
baseurl=
gpgcheck=1
gpgkey=
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=
gpgcheck=1
gpgkey=
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=
gpgcheck=1
enabled=0
gpgkey=
此时如果你就进行保存,退出!然后yum update!我保证会出问题!
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base.
Please verify its path and try again
怎么办呢?其实是因为rhel在作怪,
我们来看个东西
[base]
name=CentOS-$releasever - Base
baseurl=$releasever/os/$basearch/
gpgcheck=1
gpgkey=
看到$releasever参数没有?在centos中能自动识别版本,但是rhel中不行。这是我得出的初步结论,没得到确切答案!暂且这样理解!
那如何解决呢?问题出现了,一定得解决啊!这才是主要的!
在vim的末行模式下,键入:g/$releasever/s//5/g,用5替换掉所有$releasever参数。
rpm --import
yum clean all
yum update
一切完成,ok!