yum的安裝與配置

小亮520cl發表於2015-08-29
如果機器上沒有yum首先安裝yum

  1. 下載新的yum包
  2. 64位linux系統下載安裝包
  3. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
  4. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  5. wget http://centos.ustc.edu.cn/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm
  6. 32位linux系統下載安裝包
  7. wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
  8. wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
  9. wget http://centos.ustc.edu.cn/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-4.el5.i386.rpm

 centos6的源
 

# rpm -ivh yum-3.2.29-30.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

注:這一步要兩個一起安裝,要不會會出現如下錯誤:


一.配置本地yum源
 

點選(此處)摺疊或開啟

  1. 方法略~~~


二:.配置網路yum源
  
  1. 1.配置epel源


  1. 1.如果你使用的是RHEL6.x,CentOS6.x,Scientific6.x等6.x的RHEL系linux的話,執行:

  2. [root@test ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm

  3. 2.如果你使用的是5.x系列的,執行:

  4. [root@test ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

  5. 3.如果你使用的是4.x系列的,執行:

  6. [root@test ~]# rpm -ivh http://download.fedoraproject.org/pub/epel/4/i386/epel-release-4-10.noarch.rpm

  7. 其實上面安裝的那個包就是在你係統/etc/yum.repos.d/下釋放了2個yum源的repo檔案而已:

  8. /etc/yum.repos.d/epel.repo 正式版,所有的軟體都是穩定可以信賴的
  9. /etc/yum.repos.d/epel-testing.repo 測試版
  10. 但是預設情況下,只有正式版是有效狀態的,如果你想試試測試版的話,需要修改/etc/yum.repos.d/epel-testing.repo,把enabled=0改成enabled=1即可。

  11. 另外,如果你要使用yumdownloader來下載src.rpm包的話,需要把epel.repo裡[epel-source]域下的enabled=0也改成enabled=1即可。

  12. 當然了,如果你暫時不想使用EPEL的yum源的話,把對應檔案裡的enabled=1改成enabled=0就行了,如果你完全不需要了,那就直接解除安裝掉:

  13. [root@test ~]# rpm -e epel-release                 刪除epel源
  14. [root@test ~]# yum repolist                        檢視epel源的具體資訊
  15. [root@test ~]# yum install -y htop                 測試一下看可不可以


  1. 2.配置remi源

    1. 獲取安裝包
    2. [root@test ~]# #wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

    3. [root@test ~]# rpm -ivh remi-release-5.rpm

    4. 在 /etc/yum.repos.d/下釋放了1個yum源的repo檔案
    5. [root@gc1.cuug.net: /etc/yum.repos.d]$ ls
      CentOS-Base.repo  epel.repo  epel-testing.repo  remi-release-5.rpm  remi.repo  yum.repo.old


    6. 當有多個repo源的時候我們可以指定yum源來安裝軟體
    7. [root@gc1.cuug.net: /etc/yum.repos.d]$ yum --enablerepo=remi repolist
    8. Loaded plugins: fastestmirror
    9. Loading mirror speeds from cached hostfile
    10.  * epel: mirror01.idc.hinet.net
    11.  * remi: rpms.remirepo.net
    12. repo id repo name status
    13. addons CentOS-5 - Addons 0
    14. base CentOS-5 - Base 2,791
    15. epel Extra Packages for Enterprise Linux 5 - i386 5,461
    16. extras CentOS-5 - Extras 272
    17. remi Les RPM de remi pour Enterprise Linux 5 - i386 1,937
    18. update CentOS-5 - Updates 418
    19. repolist: 10,879


    1. 安裝好後可以檢視以下remi的php和mysql版本,都提供有5.5版,但php5.5由remi-test提供,生產環境請慎用:
    2. yum --enablerepo=remi-test,remi list php mysql
    3. remi-test和remi源預設是不開啟的,需要透過--enablerepo引數指定,把/etc/yum.repos.d/remi.repo裡對應的[remi][remi-test]塊下的enabled=0改為enabled=1則為預設開啟.
    4. epel源則有fedora社群維護,裡面有很多centos官方源沒有的軟體,比如非常實用的命令列介面工作管理員htop:
    5. yum --enablerepo=epel -y install htop
    6. 可以省略--enablerepo=epel,因為epel預設是開啟,而epel-testing是預設不開啟的,要預設開啟,修改同上.





   3.配置其它yum源

點選(此處)摺疊或開啟


  1.   1>centos的配置源

      1.    下載yum的配置源
      2. wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo 下載到 /etc/yum.repos.d/ 目錄下面
      3.    執行yum makecache生成快取

  2.    或者使用手工的方法配置

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

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

    57. 執行YUM,測試
    58. [root@linux-a ~]# yum install xmms-mp3
    59. Loading "installonlyn" plugin
    60. Loading "rhnplugin" plugin
    61. This system is not registered with RHN.
    62. RHN support will be disabled.
    63. Setting up Install Process
    64. Setting up repositories
    65. Reading repository metadata in from local files
    66. Parsing package install arguments
    67. Resolving Dependencies
    68. --> Populating transaction set with selected packages. Please wait.
    69. ---> Package xmms-mp3.i386 1:1.2.10-16.el5.rf set to be updated
    70. --> Running transaction check
    71. --> Processing Dependency: libglib-1.2.so.0 for package: xmms-mp3
    72. --> Processing Dependency: libgdk-1.2.so.0 for package: xmms-mp3
    73. --> Processing Dependency: libgthread-1.2.so.0 for package: xmms-mp3
    74. --> Processing Dependency: libgmodule-1.2.so.0 for package: xmms-mp3
    75. --> Processing Dependency: libgtk-1.2.so.0 for package: xmms-mp3
    76. --> Processing Dependency: libxmms.so.1 for package: xmms-mp3
    77. --> Restarting Dependency Resolution with new changes.
    78. --> Populating transaction set with selected packages. Please wait.
    79. ---> Package xmms.i386 1:1.2.10-14.el5.rf set to be updated
    80. ---> Package glib.i386 1:1.2.10-20.el5 set to be updated
    81. ---> Downloading header for gtk+ to pack into transaction set.
    82. gtk+-1.2.10-56.el5.i386.r 100% |=========================| 25 kB 00:00
    83. ---> Package gtk+.i386 1:1.2.10-56.el5 set to be updated
    84. --> Running transaction check
    85. --> Processing Dependency: libmikmod.so.2 for package: xmms
    86. --> Processing Dependency: gdk-pixbuf >= 0.18.0 for package: gtk+
    87. --> Restarting Dependency Resolution with new changes.
    88. --> Populating transaction set with selected packages. Please wait.
    89. ---> Downloading header for gdk-pixbuf to pack into transaction set.
    90. gdk-pixbuf-0.22.0-25.el5. 100% |=========================| 16 kB 00:00
    91. ---> Package gdk-pixbuf.i386 1:0.22.0-25.el5 set to be updated
    92. ---> Downloading header for mikmod to pack into transaction set.
    93. mikmod-3.1.6-38.1.i386.rp 100% |=========================| 7.7 kB 00:00
    94. ---> Package mikmod.i386 0:3.1.6-38.1 set to be updated
    95. --> Running transaction check
    96. Dependencies Resolved
    97. =============================================================================
    98.  Package Arch Version Repository Size
    99. =============================================================================
    100. Installing:
    101.  xmms-mp3 i386 1:1.2.10-16.el5.rf dag 179 k
    102. Installing for dependencies:
    103.  gdk-pixbuf i386 1:0.22.0-25.el5 base 231 k
    104.  glib i386 1:1.2.10-20.el5 base 137 k
    105.  gtk+ i386 1:1.2.10-56.el5 base 923 k
    106.  mikmod i386 3.1.6-38.1 base 201 k
    107.  xmms i386 1:1.2.10-14.el5.rf dag 2.3 M
    108. Transaction Summary
    109. =============================================================================
    110. Install 6 Package(s)
    111. Update 0 Package(s)
    112. Remove 0 Package(s)
    113. Total download size: 3.9 M
    114. Is this ok [y/N]:


  3.   2>其它常用yum源
  4.    網易(163)yum源是國內最好的yum源之一 ,無論是速度還是軟體版本,都非常的不錯,將yum源設定為163yum,可以提升軟體包安裝和更新的速度,同時避免一些常見軟體版本無法找到。具體設定方法如下:
  5. 1,進入yum源配置目錄
  6. cd /etc/yum.repos.d
  7. 2,備份系統自帶的yum源
  8. mv CentOS-Base.repo CentOS-Base.repo.bk
  9. 下載163網易的yum源:
  10. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
  11. 3,更新玩yum源後,執行下邊命令更新yum配置,使操作立即生效
  12. yum makecache
  13. 4,除了網易之外,國內還有其他不錯的yum源,比如中科大和搜狐的,大家可以根據自己需求下載
  14. 中科大的yum源:
  15. wget http://centos.ustc.edu.cn/CentOS-Base.repo
  16. sohu的yum源
  17. wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
  18. 理論上講,這些yum源redhat系統以及fedora也是可以用 的,但是沒有經過測試,需要的站長可以自己測試一下


一般碰到需要安裝包什麼的需求時我一般都是這樣做的:
本地yum源安裝>epel/remi源安裝>其它yum源安裝
按這個步驟一般的安裝包問題或者依賴關係基本都能解決~~~

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-1785734/,如需轉載,請註明出處,否則將追究法律責任。

相關文章