1.下载yum的rpm安装包(由于linux测试虚机没有外网地址,实际是本机浏览器下载的)

2.[root@localhostrpm]#

wgethttp://vault.centos.org/5.5/os/x86_64/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm

3.安装目录/usr/lib/rpm

4.[root@localhostrpm]#rpm-qa|grepyum//确定没有安装yum的rpm包

5.安装下载的包

[root@localhostrpm]#rpm-ivhyum-3.2.22-26.el5.centos.noarch.rpm

warning:yum-3.2.22-26.el5.centos.noarch.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

error:Faileddependencies:

yum-fastestmirrorisneededbyyum-3.2.22-26.el5.centos.noarch

yum-metadata-parser>=1.1.0isneededbyyum-3.2.22-26.el5.centos.noarch

报出缺少的依赖的包

5.1下载依赖

http://vault.centos.org/5.5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

http://vault.centos.org/5.5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm

5.2安装依赖

[root@localhostrpm]#rpm-ivhyum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm

error:Faileddependencies:

libxml2.so.2()(64bit)isneededbyyum-metadata-parser-1.1.2-3.el5.centos.x86_64

报出缺少的依赖的包

5.3再次下载依赖,并安装

http://vault.centos.org/5.5/os/x86_64/CentOS/libxml2-2.6.26-2.1.2.8.x86_64.rpm

[root@localhostrpm]#rpm-ivhyum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm

warning:yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

Preparing...###########################################[100%]

1:yum-metadata-parser###########################################[100%]

[root@localhostrpm]#rpm-ivhlibxml2-2.6.26-2.1.2.8.x86_64.rpm

warning:libxml2-2.6.26-2.1.2.8.x86_64.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

Preparing...###########################################[100%]

packagelibxml2-2.6.26-2.1.2.8.x86_64isalreadyinstalled

6.检验一下yum包的依赖情况

[root@localhostrpm]#rpm-ivhyum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

warning:yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

error:Faileddependencies:

yum>=3.0isneededbyyum-fastestmirror-1.1.16-14.el5.centos.1.noarch

[root@localhostrpm]#rpm-ivhyum-3.2.22-26.el5.centos.noarch.rpm

warning:yum-3.2.22-26.el5.centos.noarch.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

error:Faileddependencies:

yum>=3.0isneededbyyum-3.2.22-26.el5.centos.noarch

7.两个一起安装解决

[root@localhostrpm]#rpm-ivhyum-3.2.22-26.el5.centos.noarch.rpmyum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

warning:yum-3.2.22-26.el5.centos.noarch.rpm:HeaderV3DSAsignature:NOKEY,keyIDe8562897

Preparing...###########################################[100%]

1:yum-fastestmirror###########################################[50%]

2:yum###########################################[100%]

8.有需要可以yum-yupdate

[root@localhostrpm]#yum-yupdate

Loadedplugins:fastestmirror

Repositorybaseislistedmorethanonceintheconfiguration

Repositoryupdatesislistedmorethanonceintheconfiguration

Repositoryextrasislistedmorethanonceintheconfiguration

Repositorycentosplusislistedmorethanonceintheconfiguration

Repositorycontribislistedmorethanonceintheconfiguration

Loadingmirrorspeedsfromcachedhostfile

8.1解决办法开通外网访问关系

9.解决yum无法使用

[[email protected]]#yuminstallhttpd-devel

Loadedplugins:fastestmirror

Repositorybaseislistedmorethanonceintheconfiguration

Repositoryupdatesislistedmorethanonceintheconfiguration

Repositoryextrasislistedmorethanonceintheconfiguration

Repositorycentosplusislistedmorethanonceintheconfiguration

Repositorycontribislistedmorethanonceintheconfiguration

Loadingmirrorspeedsfromcachedhostfile

YumRepoError:AllmirrorURLsarenotusingftp,http[s]orfile.

Eg.Invalidrelease/

removingmirrorlistwithnovalidmirrors:/var/cache/yum/addons/mirrorlist.txt

Error:Cannotfindavalidbaseurlforrepo:addons

解决参考网址:http://blog.csdn.net/justblues/article/details/38582139

10.重建yum缓存

[[email protected]]#yumcleanall

[[email protected]]#yummakecache

Loadedplugins:fastestmirror

Loadingmirrorspeedsfromcachedhostfile

http://mirrors.163.com/centos/5/addons/x86_64/repodata/repomd.xml:[Errno14]HTTPError404:NotFound

Tryingothermirror.

Error:Cannotretrieverepositorymetadata(repomd.xml)forrepository:addons.Pleaseverifyitspathandtryagain

10.1解决报错404

修改替换/etc/yum.repos.d/CentOS-Base.repo文件中所有类似以下地址

http://mirror.centos.org/centos/$releasever/os/$basearch/

baseurl=http://vault.centos.org/5.5/os/$basearch/

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-5

11.再次重建yum缓存

[[email protected]]#yumcleanall

[[email protected]]#yummakecache

Loadedplugins:fastestmirror

Determiningfastestmirrors

addons|951B00:00

addons/filelists|197B00:00

addons/other|192B00:00

addons/primary|204B00:00

base|2.1kB00:00

base/filelists_db|4.0MB00:11

base/other_db|11MB00:40

base/group|920kB01:19

base/primary_db|2.1MB03:21

centosplus|1.9kB00:00

centosplus/filelists_db|1.4MB01:10

centosplus/other_db|4.1MB01:16

centosplus/primary_db|92kB00:01

extras|2.1kB00:00

extras/filelists_db|227kB00:05

extras/other_db|443kB00:02

extras/group|9.7kB00:00

extras/primary_db|243kB00:08

update|1.9kB00:00

update/filelists_db|2.8MB02:09

http://vault.centos.org/5.5/updates/x86_64/repodata/filelists.sqlite.bz2:[Errno4]SocketError:timedout

Tryingothermirror.

update/primary_db|1.1MB01:48

update/filelists_db|3.9MB00:03

update/other_db|14MB23:14