1、查看当前操作系统的radhat 版本号与32/64位操作系统。
[root@localhost centos5]# more /etc/redhat-release Red Hat Enterprise Linux Server release 5.8 (Tikanga) [root@localhost centos5]# uname -a Linux localhost.localdomain 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
2、删除radhat自带的yum服务
[root@localhost centos5]# rpm -qa|grep yum |xargs rpm -e --nodeps
3、下载相应的yum 安装包并安装(安装包个数因操作系统版本号不同会有存在差异)
[root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm [root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm [root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm [root@localhost centos5]# rpm -ivh yum*.rpm
4、配置yum源(推荐使用的是163的镜像)
[root@localhost centos5]# vi /etc/yum.repos.d/CenOS-Base.repo
添加以下内容:
# CentOS-Base.repo # # 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 #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os baseurl=http://mirrors.163.com/centos/5/os/x86_64/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/5/updates/x86_64/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras baseurl=http://mirrors.163.com/centos/5/extras/x86_64/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus baseurl=http://mirrors.163.com/centos/5/centosplus/x86_64/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib baseurl=http://mirrors.163.com/centos/5/contrib/x86_64/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5
5、清除缓存并下载新的镜像缓存
[root@localhost centos5]# yum clean all [root@localhost centos5]# yum makecache
6、测试(查看当前subversion版本与检查服务器subversion版本)
[root@localhost yum.repos.d]# rpm -qa|grep subversion subversion-1.6.11-7.el5_6.4 subversion-1.6.11-7.el5_6.4 [root@localhost yum.repos.d]# yum check-update subversion Loaded plugins: fastestmirror, katello, product-id, subscription-manager Updating certificate-based repositories. Unable to read consumer identity Loading mirror speeds from cached hostfile subversion.i386 1.6.11-12.el5_10 base subversion.x86_64 1.6.11-12.el5_10 base Obsoleting Packages centos-release.x86_64 10:5-11.el5.centos base redhat-release.x86_64 5Server-5.8.0.3 installed firefox.i386 31.3.0-4.el5.centos updates firefox.i386 3.6.26-1.el5_7 installed firefox.x86_64 31.3.0-4.el5.centos updates firefox.x86_64 3.6.26-1.el5_7 installed
7、安装yum注意问题
根据Linux 的版本号安装相应的CentOS并引用CentOS版本号对应的CenOS-Base.repo文件,
(1)、如果安装了CentOS 5的yun,却引用CentOS6的源yum makecache时就会报错。
(2)、如果操作系统是Radhat 5,却安装 CentOS6 yum会导致安装时需要手动安装与升级大量的依赖包。
8、附:CentOS中国镜像网址
Asia China Zhejiang University http://mirrors.zju.edu.cn/centos/ Asia China Alibaba Cloud Computing http://mirrors.aliyun.com/centos/ Asia China Beijing Institute of Technology http://mirror.bit.edu.cn/centos/ Asia China BitComm Ltd. http://mirrors.pubyun.com/centos/ Asia China CDS China http://mirrors.yun-idc.com/centos/ ftp://mirrors.yun-idc.com/centos/ rsync://mirrors.yun-idc.com/centos/ Asia China China University of Geosciences http://mirrors.cug.edu.cn/centos/ Asia China Dalian Neusoft University of Information http://mirrors.neusoft.edu.cn/centos/ ftp://mirrors.neusoft.edu.cn/centos/ Asia China Huazhong University of Science and Technology http://mirrors.hust.edu.cn/centos/ rsync://mirrors.hust.edu.cn/centos/ Asia China NetEase http://mirrors.163.com/centos/ Asia China Northeastern University, Shenyang Liaoni http://mirror.neu.edu.cn/centos/ Asia China Northwest A&F University http://mirrors.nwsuaf.edu.cn/centos/ Asia China Qiming College of Huazhong University of Science and Technology http://mirrors.hustunique.com/centos/ rsync://mirrors.hustunique.com/centos/ Asia China Shanghai Jiao Tong University http://ftp.sjtu.edu.cn/centos/ ftp://ftp.sjtu.edu.cn/centos/ Asia China Sohu Inc, Beijing P.R. China http://mirrors.sohu.com/centos/ Asia China University of Science and Tech of China http://centos.ustc.edu.cn/centos/ Asia China - Hong Kong Asia Web Services Ltd. http://mirror.vpshosting.com.hk/pub/linux/centos/ ftp://mirror.vpshosting.com.hk/pub/linux/centos/
原文地址:http://blog.csdn.net/javaee_ssh/article/details/42400121