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

林继 VPS 知识 7,003 共写了957个字 (2012-07-13 12:23:49) 没有评论 打印 扫描二维码 百度未收录

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

  1. [root@linux-a ~]# rpm -qa |grep yum
  2. yum-metadata-parser-1.0-8.fc6
  3. yum-3.0.1-5.el5
  4. yum-rhn-plugin-0.4.3-1.el5
  5. yum-updatesd-3.0.1-5.el5

清理yum缓存:

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

配置yum更新源

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

  1. [root@linux-a ~]# vi /etc/yum.repos.d/CentOS-Base.repo
  2. [base]
  3. name=CentOS-5-Base
  4. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever5&arch=$basearch&repo=os
  5. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  6. baseurl=http://ftp.sjtu.edu.cn/centos/5/os/$basearch/
  7. gpgcheck=0
  8. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  9. #released updates
  10. [update]
  11. name=CentOS-5-Updates
  12. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=updates
  13. baseurl=http://ftp.sjtu.edu.cn/centos/5/updates/$basearch/
  14. gpgcheck=0
  15. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  16. #packages used/produced in the build but not released
  17. [addons]
  18. name=CentOS-5-Addons
  19. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=addons
  20. baseurl=http://ftp.sjtu.edu.cn/centos/5/addons/$basearch/
  21. gpgcheck=0
  22. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  23. #additional packages that may be useful
  24. [extras]
  25. name=CentOS-5-Extras
  26. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=extras
  27. baseurl=http://ftp.sjtu.edu.cn/centos/5/extras/$basearch/
  28. gpgcheck=0
  29. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  30. #additional packages that extend functionality of existing packages
  31. [centosplus]
  32. name=CentOS-5-Plus
  33. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=centosplus
  34. baseurl=http://ftp.sjtu.edu.cn/centos/5/centosplus/$basearch/
  35. gpgcheck=0
  36. enabled=0
  37. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  38. #contrib - packages by Centos Users
  39. [contrib]
  40. name=CentOS-5-Contrib
  41. #mirrorlist=http://mirrorlist.centos.org/?release=4&arch=$basearch&repo=contrib
  42. baseurl=http://ftp.sjtu.edu.cn/centos/5/contrib/$basearch/
  43. gpgcheck=0
  44. enabled=0
  45. gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos5
  46. # vi dag.repo
  47. [dag]
  48. name=Dag RPM Repository for RHEL5
  49. baseurl=http://ftp.riken.jp/Linux/dag/redhat/el5/en/$basearch/dag/
  50. enabled=1
  51. gpgcheck=0
  52. gpgkey=http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt

导入key

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

运行YUM,测试

  1. [root@linux-a ~]# yum install xmms-mp3
  2. Loading "installonlyn" plugin
  3. Loading "rhnplugin" plugin
  4. This system is not registered with RHN.
  5. RHN support will be disabled.
  6. Setting up Install Process
  7. Setting up repositories
  8. Reading repository metadata in from local files
  9. Parsing package install arguments
  10. Resolving Dependencies
  11. --> Populating transaction set with selected packages. Please wait.
  12. ---> Package xmms-mp3.i386 1:1.2.10-16.el5.rf set to be updated
  13. --> Running transaction check
  14. --> Processing Dependency: libglib-1.2.so.0 for package: xmms-mp3
  15. --> Processing Dependency: libgdk-1.2.so.0 for package: xmms-mp3
  16. --> Processing Dependency: libgthread-1.2.so.0 for package: xmms-mp3
  17. --> Processing Dependency: libgmodule-1.2.so.0 for package: xmms-mp3
  18. --> Processing Dependency: libgtk-1.2.so.0 for package: xmms-mp3
  19. --> Processing Dependency: libxmms.so.1 for package: xmms-mp3
  20. --> Restarting Dependency Resolution with new changes.
  21. --> Populating transaction set with selected packages. Please wait.
  22. ---> Package xmms.i386 1:1.2.10-14.el5.rf set to be updated
  23. ---> Package glib.i386 1:1.2.10-20.el5 set to be updated
  24. ---> Downloading header for gtk+ to pack into transaction set.
  25. gtk+-1.2.10-56.el5.i386.r 100% |=========================|  25 kB    00:00     
  26. ---> Package gtk+.i386 1:1.2.10-56.el5 set to be updated
  27. --> Running transaction check
  28. --> Processing Dependency: libmikmod.so.2 for package: xmms
  29. --> Processing Dependency: gdk-pixbuf >= 0.18.0 for package: gtk+
  30. --> Restarting Dependency Resolution with new changes.
  31. --> Populating transaction set with selected packages. Please wait.
  32. ---> Downloading header for gdk-pixbuf to pack into transaction set.
  33. gdk-pixbuf-0.22.0-25.el5. 100% |=========================|  16 kB    00:00     
  34. ---> Package gdk-pixbuf.i386 1:0.22.0-25.el5 set to be updated
  35. ---> Downloading header for mikmod to pack into transaction set.
  36. mikmod-3.1.6-38.1.i386.rp 100% |=========================| 7.7 kB    00:00     
  37. ---> Package mikmod.i386 0:3.1.6-38.1 set to be updated
  38. --> Running transaction check
  39. Dependencies Resolved
  40. =============================================================================
  41.  Package                 Arch       Version          Repository        Size 
  42. =============================================================================
  43. Installing:
  44.  xmms-mp3                i386       1:1.2.10-16.el5.rf  dag               179 k
  45. Installing for dependencies:
  46.  gdk-pixbuf              i386       1:0.22.0-25.el5  base              231 k
  47.  glib                    i386       1:1.2.10-20.el5  base              137 k
  48.  gtk+                    i386       1:1.2.10-56.el5  base              923 k
  49.  mikmod                  i386       3.1.6-38.1       base              201 k
  50.  xmms                    i386       1:1.2.10-14.el5.rf  dag               2.3 M
  51. Transaction Summary
  52. =============================================================================
  53. Install      6 Package(s)         
  54. Update       0 Package(s)         
  55. Remove       0 Package(s)        
  56. Total download size: 3.9 M
  57. Is this ok [y/N]:
  1. [rhel-debuginfo]
  2. name=Red Hat Enterprise Linux $releasever - $basearch - Debug
  3. baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
  4. enabled=0
  5. gpgcheck=1
  6. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  7. [rhel-debuginfo-beta]
  8. name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
  9. baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
  10. enabled=0
  11. gpgcheck=1
  12. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
  13.  
  14. [base]
  15. name=Red Hat Enterprise Linux $releasever -Base
  16. baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
  17. gpgcheck=1
  18. gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  19. [update]
  20. name=Red Hat Enterprise Linux $releasever -Updates
  21. baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
  22. gpgcheck=1
  23. gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  24. [extras]
  25. name=Red Hat Enterprise Linux $releasever -Extras
  26. baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
  27. gpgcheck=1
  28. gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5
  29. [addons]
  30. name=Red Hat Enterprise Linux $releasever -Addons
  31. baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
  32. gpgcheck=1 
  33. gpgkey=http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

日本升级源

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client.  You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you, as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12.  
  13. [base]
  14. name=CentOS-$releasever – Base
  15. baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/os/$basearch/
  16. gpgcheck=1
  17. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  18.  
  19. #released updates
  20. [updates]
  21. name=CentOS-$releasever – Updates
  22. baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/updates/$basearch/
  23. gpgcheck=1
  24. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  25.  
  26. #additional packages that may be useful
  27. [extras]
  28. name=CentOS-$releasever – Extras
  29. baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/extras/$basearch/
  30. gpgcheck=1
  31. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  32.  
  33. #additional packages that extend functionality of existing packages
  34. [centosplus]
  35. name=CentOS-$releasever – Plus
  36. baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/centosplus/$basearch/
  37. gpgcheck=1
  38. enabled=0
  39. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  40.  
  41. #contrib – packages by Centos Users
  42. [contrib]
  43. name=CentOS-$releasever – Contrib
  44. baseurl=http://ftp.tsukuba.wide.ad.jp/Linux/centos/$releasever/contrib/$basearch/
  45. gpgcheck=1
  46. enabled=0
  47. 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

历史上的今天

7月
13

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

< >