RedHat是美国RedHat公司的产品,是相当成功的一个Linux发行版本,也是目前使用最多的Linux发行版本。由于Redhat的yum在线更新是收费的,如果没有注册的话是不能使用的,即不能在线安装软件。在这种情况下,想使用Redhat系统,还想用yum源来在线安装软件,有没有办法?答案是有办法,请往下看!
今天碰上要给一台装有Linux的机器做维护,于是就以为按照以往经验就能解决问题,但是神奇的发现机器上一堆的软件包都没有安装,最要命的是连软件包管理器也都没有安装,本以为是FreeBSD,查了一下才发现是RedHat Linux Server 5.4,于是开始着手安装YUM,在Google搜索了一下,发现貌似类似的情况不多,但是这确实不是我第一次遇到RedHat没有yum了,因为上次遇到的时候是别人让帮忙看看,解决不了也就没留心,但这次维护是必要的,于是尝试了许久,这大概是我最不舒服的一次经历了,而且RedHat很多资源都不多,于是基本rpm包都是借助了CentOS 5,于是对RedHat充满了怨念。
网易开源的镜像站 :http://mirrors.163.com/
根据的你的Redhat的版本,选择相应的Centos的源路径
我的OS是x86_64 Redhat5,对应的rpm路径 http://mirrors.163.com/centos/5/os/x86_64/
首先需要确定系统架构
确认是x86_64之后,在网易的mirrors下载需要的rpm包:(如果是i386的话则需要到
http://mirrors.163.com/centos/5/os/i386/CentOS/ 找到对应的软件包)
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/m2crypto-0.16-8.el5.x86_64.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-elementtree-1.2.6-5.x86_64.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-sqlite-1.1.7-1.2.1.x86_64.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-urlgrabber-3.1.0-6.el5.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-37.el5.centos.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-16.el5.centos.noarch.rpm
wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
或者从 http://www.rpmfind.net/ 下载最新yum
-rwxrwxrwx 1 root root 1034902 Apr 1 2012 yum-3.2.22-39.el5.centos.noarch.rpm
-rwxrwxrwx 1 root root 21033 Apr 1 2012 yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
-rwxr–r– 1 root root 26053 Apr 1 2012 yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
这里我把这些需要的yum rpm包打包在一起,需要的可以下载:
百度云盘:http://pan.baidu.com/s/1mgoO7na
(不要问我其他文件是干嘛用的,俺也是菜鸟不知道,64位的请删除yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm和yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm)
安装过程中,要注意自己的系统是32位还是64位,我在第3步遇到这个问题引起的麻烦
yum-metadata-parser-1.1.2-3.el5.centos.x86_64 是64位的
yum-metadata-parser-1.1.2-3.el5.centos.i386 是32位的
1.查看已有的yum
[[email protected] ~/build]
# rpm -qa|grep yum
yum-rhn-plugin-0.5.4-13.el5
yum-3.2.22-20.el5
yum-updatesd-0.9-2.el5
yum-security-1.1.16-13.el5
yum-metadata-parser-1.1.2-3.el5
2.卸载已有的yum并确认卸载成功
[[email protected] ~/build]
# rpm -qa | grep yum |xargs rpm -e –nodeps
[[email protected] ~/build]
# rpm -qa|grep yum
[[email protected] ~/build]
3. 安装 yum 但遇到问题
用一个命令同时安装多个包可以解决这些包之间的依赖问题
[[email protected] ~/build/yum]
# rpm -ivh yum-*
warning: yum-3.2.22-39.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
error: Failed dependencies:
libc.so.6()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libc.so.6(GLIBC_2.2.5)(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libglib-2.0.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libm.so.6()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libpthread.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libsqlite3.so.0()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libxml2.so.2()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
libz.so.1()(64bit) is needed by yum-metadata-parser-1.1.2-3.el5.centos.x86_64
遇到这个问题第一判断是缺包,我又安装了libc,但是仍然出这个问题,后来才发现是yum-metadata-parser包的类型搞错了,我
download的是64位,我需要的是32位,汗一个。
插播glibc的安装,
下载了两个glibc的包,然后用rpm -ivh glibc-* 来安装。
# ll glibc-*
-rw-r–r– 1 root root 4989324 Feb 8 17:02 glibc-2.5-65.x86_64.rpm
-rwxr–r– 1 root root 17291363 Feb 8 17:27 glibc-common-2.5-65.x86_64.rpm
4. 再次安装成功,
[[email protected] ~/build/yum]
# rpm -ivh yum-*
warning: yum-3.2.22-39.el5.centos.noarch.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
Preparing… ########################################### [100%]
1:yum-metadata-parser ########################################### [ 33%]
2:yum-fastestmirror ########################################### [ 67%]
3:yum ########################################### [100%]
5.导入证书(证书的位置 http://mirrors.163.com/centos/)
rpm -import http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
6.让yum使用网易的源:
#cd /etc/yum.repos.d/
#wget http://mirrors.163.com/.help/CentOS-Base-163.repo
7.使用
#vi CentOS-Base-163.repo
在所有mirrorlist前面加上#,把所有$releasever替换成5,保存
5.清理并重新生成yum缓存
#yum clean metadata
#yum makecache
6.于是yum就正常工作了,然后随手就更新一下,就OK了
#yum -y upgrade
以下是Redhat 5使用上海交大的yum源
首先我们通过rpm -qa | grep yum看一下目前的的REDHAT上面的YUM的安装包
删除如下三个包,其它的可不用管,事实上管了会出现相关问题
rpm -e yum-updatesd-3.0.1-5.el5
rpm -e yum-rhn-plugin-0.4.3-1.el5
rpm -e yum-3.0.1-5.el5
删除了以后下载centos的源安装包,如下:
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm
wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
通过rpm -ivh 安装以上四个包文件,完成以后
touch /etc/yum.repos.d/CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
以下是上海交大的yum源:
[base]
name=CentOS-5 – Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&
repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/os/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#released updates
[update]
name=CentOS-5 – Updates
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/updates/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#packages used/produced in the build but not released
[addons]
name=CentOS-5 – Addons
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/addons/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that may be useful
[extras]
name=CentOS-5 – Extras
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/extras/$basearch/
gpgcheck=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5 – Plus
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/centosplus/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
#contrib – packages by Centos Users
[contrib]
name=CentOS-5 – Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
baseurl=http://ftp.sjtu.edu.cn/centos/5.5/contrib/$basearch/
gpgcheck=0
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
完成以后运行yum update