替換 RHEL5的yum源爲CentOS5源,親測線上系統可用

 

最近安裝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. 也可用此地址: 
  7. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm 
  8. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-39.el5.centos.noarch.rpm 
  9. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm 
  10. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm 
  11. wget http://sudone.com/download/CentOS-Base.repo -O /etc/yum.repos.d/CentOS-Base.repo 
  12.  
  13. key文件位置可選: 
  14. http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  15. http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5 
  16. 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. ###### 配置文件完整內容 ###### 
  4. [base] 
  5. name=CentOS-5 - Base 
  6. repo=os 
  7. baseurl=http://mirrors.163.com/centos/5/os/$basearch/ 
  8. gpgcheck=1 
  9. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  10.  
  11. #released updates 
  12. [update
  13. name=CentOS-5 - Updates 
  14. baseurl=http://mirrors.163.com/centos/5/updates/$basearch/ 
  15. gpgcheck=1 
  16. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  17.  
  18. #packages used/produced in the build but not released 
  19. [addons] 
  20. name=CentOS-5 - Addons 
  21. baseurl=http://mirrors.163.com/centos/5/addons/$basearch/ 
  22. gpgcheck=1 
  23. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  24.  
  25. #additional packages that may be useful 
  26. [extras] 
  27. name=CentOS-5 - Extras 
  28. baseurl=http://mirrors.163.com/centos/5/extras/$basearch/ 
  29. gpgcheck=1 
  30. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  31.  
  32. #additional packages that extend functionality of existing packages 
  33. [centosplus] 
  34. name=CentOS-5 - Plus 
  35. baseurl=http://mirrors.163.com/centos/5/centosplus/$basearch/ 
  36. gpgcheck=1 
  37. enabled=0 
  38. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  39.  
  40. #contrib - packages by Centos Users 
  41. [contrib] 
  42. name=CentOS-5 - Contrib 
  43. baseurl=http://mirrors.163.com/centos/5/contrib/$basearch/ 
  44. gpgcheck=1 
  45. enabled=0 
  46. gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-5 
  47. ###### 配置文件結束 ###### 

 

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 ~]#  

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章