最近安装nagios+pnp,各种依赖包啊。rrdtool肿么装的这么费劲,后来实在扛不住了,还是修改rhel的源吧,把yum源搞成centos的不就ok了!哈哈。然后就从网上一顿猛搜,发现“Ayou”老师的文章很靠谱,很有帮助,这里是看“Ayou”老师的文章搭出来的。虽然不是太难,但是找这个CentOS-Base.repo还是要靠“ayou”老师的文章,所以,感谢下“Ayou”老师。顺便推荐“Ayou”老师的博客,有很多很多好的文章,篇幅很短,但很精练。

由于我的系统环境是x86_64的,“Ayou”老师的路径是i386的,所以稍微改了一点Ayou老师源地址的路径,还有一点就是把gpgkey的路径换成了163的路径,因为感觉每次访问gpgkey都要去国外的服务器跑一圈是不是有点绕了。当然把这个gpgkey放在本地也是合适的,但是,个人认为在没有互联网访问的情况下,yum源本身就是无法连通的,这个gpgkey也确实就没有必要存在,所以这里就没有拿回本地来。

推荐博客:http://www.sudone.com/

本文参考:http://sudone.com/linux/rhel5_yum.html

1、卸载掉RHEL原有的yum包

  1. rpm -aq|grep yum|xargs rpm -e --nodeps

2、下载centos的yum安装文件

  1. wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
  2. wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
  3. wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
  4. wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  5. 也可用此地址:
  6. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
  7. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm
  8. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm
  9. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  10. wget http://sudone.com/download/CentOS-Base.repo -O /etc/yum.repos.d/CentOS-Base.repo
  11. key文件位置可选:
  12. http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  13. http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
  14. http://mirrors.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

3、安装yum软件包

  1. rpm -ivh --nodeps \
  2. # python-iniparse-0.2.3-4.el5.noarch.rpm \
  3. yum-3.2.22-39.el5.centos.noarch.rpm \
  4. yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm \
  5. yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm

4、添加配置文件

  1. wget http://sudone.com/download/CentOS-Base.repo -O /etc/yum.repos.d/CentOS-Base.repo

5、以防万一,配置文件全文如下

  1. # cat /etc/yum.repos.d/CentOS-Base.repo
  2. ###### 配置文件完整内容 ######
  3. [base]
  4. name=CentOS-5 - Base
  5. repo=os
  6. baseurl=http://mirrors.163.com/centos/5/os/$basearch/
  7. gpgcheck=1
  8. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  9. #released updates
  10. [update]
  11. name=CentOS-5 - Updates 
  12. baseurl=http://mirrors.163.com/centos/5/updates/$basearch/
  13. gpgcheck=1
  14. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  15. #packages used/produced in the build but not released
  16. [addons]
  17. name=CentOS-5 - Addons
  18. baseurl=http://mirrors.163.com/centos/5/addons/$basearch/
  19. gpgcheck=1
  20. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  21. #additional packages that may be useful
  22. [extras]
  23. name=CentOS-5 - Extras
  24. baseurl=http://mirrors.163.com/centos/5/extras/$basearch/
  25. gpgcheck=1
  26. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  27. #additional packages that extend functionality of existing packages
  28. [centosplus]
  29. name=CentOS-5 - Plus
  30. baseurl=http://mirrors.163.com/centos/5/centosplus/$basearch/
  31. gpgcheck=1
  32. enabled=0
  33. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  34. #contrib - packages by Centos Users
  35. [contrib]
  36. name=CentOS-5 - Contrib
  37. baseurl=http://mirrors.163.com/centos/5/contrib/$basearch/
  38. gpgcheck=1
  39. enabled=0
  40. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5
  41. ###### 配置文件结束 ######

6、万事大吉,可以测试了

以下代码为展示,不用敲,只为验证yum是否能连到yum源上。经过下面测试已经可以显示包了,ok。哈哈。配置完成,

  1. [root@localhost ~]# yum search httpd
  2. Loaded plugins: fastestmirror
  3. Repository base is listed more than once in the configuration
  4. Repository update is listed more than once in the configuration
  5. Repository addons is listed more than once in the configuration
  6. Repository extras is listed more than once in the configuration
  7. Repository centosplus is listed more than once in the configuration
  8. Repository contrib is listed more than once in the configuration
  9. Loading mirror speeds from cached hostfile
  10. addons                                                   | 1.9 kB     00:00
  11. base                                                     | 1.1 kB     00:00
  12. extras                                                   | 2.1 kB     00:00
  13. update                                                   | 1.9 kB     00:00
  14. ================================ Matched: httpd ================================
  15. mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP server
  16. system-config-httpd.noarch : Apache configuration tool
  17. centos-ds.x86_64 : CentOS Directory, Administration, and Console Suite
  18. httpd.x86_64 : Apache HTTP Server
  19. httpd-devel.x86_64 : Development tools for the Apache HTTP server.
  20. httpd-devel.i386 : Development tools for the Apache HTTP server.
  21. httpd-manual.x86_64 : Documentation for the Apache HTTP server.
  22. mod_dav_svn.x86_64 : Apache server module for Subversion server.
  23. [root@localhost ~]#