首页 » VPS 知识 » 浏览内容

配置Redhat Enterprise Linux 5.4使用CentOS的更新源


2012-07-13 12:23:49 6,105 0 发表评论 字体: 作者:C.K.

体验版 88 元,个人版 128 元,多用户版 288元个人版160元升级到多用户版。

YUM是Redhat Linux在线安装更新及软件的工具,但是这是RHEL5的收费功能,如果没有购买Redhat的服务时不能使用RHEL5的更新源的,会提示注册。
由于CentOS是从Redhat演化而来的免费Linux版本,因此可以利用CentOS的yum更新源来实现RHEL5的YUM功能。配置方法如下:
检查yum是否安装,默认情况下都是安装好的,总共4各包。

[root@linux-a ~]# rpm -qa |grep yum
  • yum-metadata-parser-1.0-8.fc6
  • yum-3.0.1-5.el5
  • yum-rhn-plugin-0.4.3-1.el5
  • yum-updatesd-3.0.1-5.el5
  • 清理yum缓存:

    # yum clean all
  • # yum makecache     #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
  • # yum install vim*    #测试域名是否可用
  • 配置yum更新源

    创建/etc/yum.repos.d/CentOS-Base.repo文件,定义yum更新源,这里使用的是上海交大的CentOS更新源

    [root@linux-a ~]# vi /etc/yum.repos.d/CentOS-Base.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=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/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/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/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/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/contrib/$basearch/
  • gpgcheck=0
  • 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=0
  • gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
  • 导入key

    [root@linux-a ~]# rpm --import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

    运行YUM,测试

    [root@linux-a ~]# yum install xmms-mp3
  • Loading "installonlyn" plugin
  • Loading "rhnplugin" plugin
  • This system is not registered with RHN.
  • RHN support will be disabled.
  • Setting up Install Process
  • Setting up repositories
  • Reading repository metadata in from local files
  • Parsing package install arguments
  • Resolving Dependencies
  • --> Populating transaction set with selected packages. Please wait.
  • ---> Package xmms-mp3.i386 1:1.2.10-16.el5.rf set to be updated
  • --> Running transaction check
  • --> Processing Dependency: libglib-1.2.so.0 for package: xmms-mp3
  • --> Processing Dependency: libgdk-1.2.so.0 for package: xmms-mp3
  • --> Processing Dependency: libgthread-1.2.so.0 for package: xmms-mp3
  • --> Processing Dependency: libgmodule-1.2.so.0 for package: xmms-mp3
  • --> Processing Dependency: libgtk-1.2.so.0 for package: xmms-mp3
  • --> Processing Dependency: libxmms.so.1 for package: xmms-mp3
  • --> Restarting Dependency Resolution with new changes.
  • --> Populating transaction set with selected packages. Please wait.
  • ---> Package xmms.i386 1:1.2.10-14.el5.rf set to be updated
  • ---> Package glib.i386 1:1.2.10-20.el5 set to be updated
  • ---> Downloading header for gtk+ to pack into transaction set.
  • gtk+-1.2.10-56.el5.i386.r 100% |=========================|  25 kB    00:00    
  • ---> Package gtk+.i386 1:1.2.10-56.el5 set to be updated
  • --> Running transaction check
  • --> Processing Dependency: libmikmod.so.2 for package: xmms
  • --> Processing Dependency: gdk-pixbuf >= 0.18.0 for package: gtk+
  • --> Restarting Dependency Resolution with new changes.
  • --> Populating transaction set with selected packages. Please wait.
  • ---> Downloading header for gdk-pixbuf to pack into transaction set.
  • gdk-pixbuf-0.22.0-25.el5. 100% |=========================|  16 kB    00:00    
  • ---> Package gdk-pixbuf.i386 1:0.22.0-25.el5 set to be updated
  • ---> Downloading header for mikmod to pack into transaction set.
  • mikmod-3.1.6-38.1.i386.rp 100% |=========================| 7.7 kB    00:00    
  • ---> Package mikmod.i386 0:3.1.6-38.1 set to be updated
  • --> Running transaction check
  • Dependencies Resolved
  • =============================================================================
  •  Package                 Arch       Version          Repository        Size
  • =============================================================================
  • Installing:
  •  xmms-mp3                i386       1:1.2.10-16.el5.rf  dag               179 k
  • Installing for dependencies:
  •  gdk-pixbuf              i386       1:0.22.0-25.el5  base              231 k
  •  glib                    i386       1:1.2.10-20.el5  base              137 k
  •  gtk+                    i386       1:1.2.10-56.el5  base              923 k
  •  mikmod                  i386       3.1.6-38.1       base              201 k
  •  xmms                    i386       1:1.2.10-14.el5.rf  dag               2.3 M
  • Transaction Summary
  • =============================================================================
  • Install      6 Package(s)        
  • Update       0 Package(s)        
  • Remove       0 Package(s)        
  • Total download size: 3.9 M
  • Is this ok [y/N]:
  • [rhel-debuginfo]
  • name=Red Hat Enterprise Linux $releasever - $basearch - Debug
  • baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
  • enabled=0
  • gpgcheck=1
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  • [rhel-debuginfo-beta]
  • name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
  • baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
  • enabled=0
  • gpgcheck=1
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  • [base]
  • name=Red Hat Enterprise Linux $releasever -Base
  • baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
  • gpgcheck=1
  • gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  • [update]
  • name=Red Hat Enterprise Linux $releasever -Updates
  • baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
  • gpgcheck=1
  • gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  • [extras]
  • name=Red Hat Enterprise Linux $releasever -Extras
  • baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
  • gpgcheck=1
  • gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  • [addons]
  • name=Red Hat Enterprise Linux $releasever -Addons
  • baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
  • gpgcheck=1
  • gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  • 日本升级源

    # 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
  • baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/os/$basearch/
  • gpgcheck=1
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  • #released updates
  • [updates]
  • name=CentOS-$releasever – Updates
  • baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/updates/$basearch/
  • gpgcheck=1
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  • #additional packages that may be useful
  • [extras]
  • name=CentOS-$releasever – Extras
  • baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/extras/$basearch/
  • gpgcheck=1
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  • #additional packages that extend functionality of existing packages
  • [centosplus]
  • name=CentOS-$releasever – Plus
  • baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/centosplus/$basearch/
  • gpgcheck=1
  • enabled=0
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  • #contrib – packages by Centos Users
  • [contrib]
  • name=CentOS-$releasever – Contrib
  • baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/contrib/$basearch/
  • gpgcheck=1
  • enabled=0
  • gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  • 结果出现错误:

    warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
    GPG key retrieval failed: [Errno 14] HTTP Error 404: Not Found
    此时,将gpgcheck=1改成gpgcheck=0即可。

    第二种方法:

    #rpm –import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
    导入key (没有实际试过)
    #rpm –import http://ftp.sjtu.edu.cn/centos/5/os/i386/RPM-GPG-KEY-CentOS-5

    ======================================

    另外,如果服务器需要通过代理上网,则需要设置一下代理服务器才能进行联网更新:
    在 /etc/yum.conf文件加入下面一行内容,指定一下代理服务器参数:

    #Set http proxy
    proxy=http://192.168.1.100:8000

      网站统计 Statistics

      • 创建时间: 2005年1月3日 距今4947 天
      • 日志总数: 2461
      • 评论总数: 630
      • 标签总数: 654
      • 链接总数: 273
      • 最后更新: 2017-7-1 18:16:33
      • 您是本站第 13720993 位访客

      广告区 Guǎng Gào