您的位置:首页 > 运维架构 > Linux

Redhat 5.2 Yum 配置

2012-05-09 10:09 363 查看
转:http://hi.baidu.com/fisherman86/blog/item/d95e06d0550c5e0b3af3cfb1.html

Redhat 5.2 Yum 配置

2010-03-07 5:48
        最近作FPGA的DSP开发,经常在一些论坛上看到说在Linux下跑Matlab的速度非常的快,于是决定装个Linux来试试。由于FPGA的开发工具对系统的要求是要Redhat Enterprise 4/5,所以选择Redhat5。

由于对Linux操作系统没有太多基础,只是读书的时候接触过一下。所以对其配置有很多搞不懂的,幸好有强大的网络可以支持。

目前网上很多介绍的方法用的都是配置rhel 5 使用CentOS的yum站点升级

具体方法如下:

首先,rhel5系统安装的时候其实已经有yum了,只是因为如果用官方的网站更新的话除非你是用钱买的rhel5.否则它会提示注册之类的。所以只要把 yum的更新地址改成开源的就行了。而限定yum更新地址的文件在/etc/yum.repos.d/里。

1、先把它们改成备份文件,即在后面加.bak。

# mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.bak 

# mv /etc/yum.repos.d/rpmforge.repo.rpmnew /etc/yum.repos.d/rpmforge.repo.rpmnew.bak (这个文件Client版本没有,可以省略这步。)

# mv /etc/yum.conf /etc/yum.conf.bak 

2、建立新的配置文件: 

# cd /etc/yum.repos.d 

# touch rhel-debuginfo.repo 

# touch mirrors-rpmforge 

# touch rpmforge.repo 

# cd ..

# touch yum.conf

3、编辑新建的/etc/yum.repos.d/rhel-debuginfo.repo文件,将其内容修改为:

[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/os/$basearch/

gpgcheck=1

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/updates/$basearch/

gpgcheck=1

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/addons/$basearch/

gpgcheck=1

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/extras/$basearch/

gpgcheck=1

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/centosplus/$basearch/

gpgcheck=1

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/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5

# vi dag.repo

[dag]

name=Dag RPM Repository for RHEL5

baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/

enabled=1

gpgcheck=1

gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt

4、编辑新建的/etc/yum.repos.d/mirrors-rpmforge.repo文件,将其内容修改为: 

http://apt.sw.be/redhat/el5/en/$ARCH/dag
http://archive.cs.uu.nl/mirror/dag.wieers/redhat/el5/en/$ARCH/dag
http://ftp2.lcpe.uni-sofia.bg/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag

#http://ftp.heanet.ie/pub/freshrpms/pub/dag/redhat/el5/en/$ARCH/dag
http://ftp-stud.fht-esslingen.de/dag/redhat/el5/en/$ARCH/dag
http://mirror.cpsc.ucalgary.ca/mirror/dag/redhat/el5/en/$ARCH/dag
http://mirrors.ircam.fr/pub/dag/redhat/el5/en/$ARCH/dag
http://rh-mirror.linux.iastate.edu/pub/dag/redhat/el5/en/$ARCH/dag
http://rpmfind.net/linux/dag/redhat/el5/en/$ARCH/dag
http://wftp.tu-chemnitz.de/pub/linux/dag/redhat/el5/en/$ARCH/dag
http://www.mirrorservice.org/sites/apt.sw.be/redhat/el5/en/$ARCH/dag

5、编辑新建的/etc/rpmforge.repo文件,将其内容修改为: 

[root@killgoogle ~]# vi rpmforge.repo 

# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag 

# URL: http://rpmforge.net/

[rpmforge] 

name = Red Hat Enterprise $releasever - RPMforge.net - dag 

#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag

mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge

#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge 

enabled = 1 

protect = 0 

gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag 

gpgcheck = 1 

6、编辑新建的/etc/yum.conf文件,将其内容修改为:

[main]

cachedir=/var/cache/yum

keepcache=1

debuglevel=2

logfile=/var/log/yum.log

pkgpolicy=newest

distroverpkg=redhat-release

tolerant=1

exactarch=1

obsoletes=1

gpgcheck=1

plugins=1

metadata_expire=1800

# PUT YOUR REPOS HERE OR IN separate files named file.repo

# in /etc/yum.repos.d

[base]

name=centos-5 - Base

baseurl=http://centos.ustc.edu.cn/centos/5/os/x86_64/

# the other site: http://centos.candishosting.com.cn/centos/5/os/x86_64/
# you can find more site in: http://www.centos.org/modules/tinycontent/index.php?id=13
enabled=1

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#released updates

[update]

name=CentOS-5 - Updates

baseurl=http://mirror.centos.org/centos/5/updates/x86_64/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#packages used/produced in the build but not released

[addons]

name=CentOS-5 - Addons

baseurl=http://mirror.centos.org/centos/5/addons/$basearch/

gpgcheck=1

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful

[extras]

name=CentOS-5 - Extras

baseurl=http://mirror.centos.org/centos/5/extras/$basearch/

gpgcheck=1

gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-5 - Plus

baseurl=http://mirror.centos.org/centos/5/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users

[contrib]

name=CentOS-5 - Contrib

baseurl=http://mirror.centos.org/centos/5/contrib/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#packages in testing

[testing]

name=CentOS-5 - Testing

baseurl=http://mirror.centos.org/centos/5/testing/$basearch/

gpgcheck=1

enabled=0

gpgkey=http://centos.ustc.edu.cn/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5 

######################### #####   end    ##################################

#注意:这里我装的是64位的系统,如果装的是32位的系统,应将上面的所有网址的x84_64改成i386.

到此就基本配置完成了,这个是中科大的源,号称每隔小时跟新一次,速度确实蛮快!

但是这样有些软件还是会找不到,为了增加资源库,可以添加livna的资源库。

具体方法是;(来自:http://rpm.livna.org/)

How to use rpm.livna.org

Graphical setup after installing Fedora

Install the livna-release package by clicking on this link and hitting Enter a few times.(¹)

Command line setup using rpm after installing Fedora

Install the livna-release package by running this command(²):
su -c "rpm -ivh http://rpm.livna.org/livna-release.rpm"[/code] 

Enabling rpm.livna.org while installing Fedora

In Fedora 10 and later you can also use the rpm.livna.org repository directly during install. It works similarly to the scheme that RPM
Fusion uses. As repo URL just use http://rpm.livna.org/repo/10/i386/ for Fedora 10, i386; adjust accordingly for other Fedora releases or other architectures like x86_64, ppc or ppc64. Please note that you must not
check the "URL is a mirror list" checkbox for rpm.livna.org.

如果网速慢的话可以通过增加yum的超时时间,这样就不会总是因为超时而退出。 

[root@killgoogle ~]vi /etc/yum.conf 

加上这么一句:timeout=120 

在用yum更新程序时出现:warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6这个警告,导致下载下来的程序没有安装。

解决遇到 Header V3 DSA signature: NOKEY, key ID 6b8d79e6这里问题的时候就是需要更新key,这里提供几个国外的key文件更新源:
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
rpm --import http://quattor.web.lal.in2p3.fr/packages/os/sl520-x86_64/base/RPM-GPG-KEYs/RPM-GPG-KEY-CentOS-5 ###############################################################################

该部分由于在安装时没遇到,所以不知其正确性,仅供参考:
到这里配置差不多就完了。还有一个包需要安装:rpmforge-release-0.3.6-1.el5.rf.i386.rpm 

如果不安装的话有可能会出现以下错误:GPG key retrieval failed: [Errno 5] OSError: [Errno 2] 没有那个文件或目录: '/etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag' 

http://rpmfind.net/linux/RPM/找到这个包,然后 

[root@killgoogle ~]rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm 

接下来就是输入KEY了。 

[root@killgoogle ~] rpm --import http://mirror.be10.com/centos/RPM-GPG-KEY-CentOS-5

这样基本上yum就可以用了。不过如果觉得不爽的话还可以优化: 

加速yum 

[root@killgoogle ~]yum install yum-fastestmirror yum-presto 

指定或去掉软件源的mirror: 

可以在baseurl中将比较慢的mirror去掉 

你的yum镜像的速度测试记录文件: 

/var/cache/yum/timedhosts.txt 

yum Existing lock 错误的解决办法 

如果系统启动的时候, yum 出现Existing lock /var/run/yum.pid: another copy is running as pid 3380. Aborting. 可以用下面的办法解决: 

[root@killgoogle ~]/etc/init.d/yum-updatesd stop 

也可以用以下方法: 

[root@killgoogle ~]rm -f /var/run/yum.pid 

主要原因就是yum在自动更新只要关掉它就可以了 

#################################################################################

 
后记:

这样运行yum update还是不行,会出错:

...

--> Processing Conflict: yum conflicts yum-rhn-plugin < 0.5.2-1.el5

--> Finished Dependency Resolution

Error: yum conflicts with yum-rhn-plugin < 0.5.2-1.el5

解决方法是把rhel自带的yum相关包都卸载掉(yum-rhn-plugin这个包当然包含于其中),

#   卸载RHEL的yum-rhn-plugin
# 卸载yum-rhn插件,否则因rhn没有注册,故无法使用yum
rpm -e yum-rhn-plugin
#       卸载RHEL的yum(这个需要解除依赖关系,要不然没办法卸载)

# yum-3.0.5-1.el5
rpm -e --nodeps yum
然后装上新的yum(redhat的安装碟里有,也可以在网上下其他的版本,在这里我懒得去网上找,直接用光碟里的yum装上)。

安装完毕用 :yum update 一下,发现就可以利用yum让rhel使用centos的源进行升级了.
       到此,大功搞成,等它慢慢去更新,睡个觉醒来肯定可以搞定,两个疯狂的傻B搞到现在,实在太佩服自己了!
后后记:
        yum update的时候忘了加个-y参数,导致睡醒的时候更新包是下完了,但是没帮我安装,下次一定要记得用上-y这一参数!

本文参照了网上的多篇文章,经过本人亲自测试通过。
参考文章: http://www.cnblogs.com/yisohoo/articles/1423940.html http://hi.baidu.com/openlamp/blog/item/0a0d1b5505cf20ceb645ae7a.html
添加livna资源库:http://rpm.livna.org/

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息