歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

RedHat Linux 5 配置 yum

1、查看當前Linux操作系統RedHat 版本號與32/64位操作系統。

[root@localhost CentOS5]# more /etc/redhat-release
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
[root@localhost centos5]# uname -a
Linux localhost.localdomain 2.6.18-308.el5 #1 SMP Fri Jan 27 17:17:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

2、刪除RedHat自帶的yum服務

[root@localhost centos5]# rpm -qa|grep yum |xargs rpm -e --nodeps

3、下載相應的yum 安裝包並安裝(安裝包個數因操作系統版本號不同會有存在差異)

[root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-40.el5.centos.noarch.rpm
[root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-21.el5.centos.noarch.rpm
[root@localhost centos5]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-4.el5.x86_64.rpm                              
[root@localhost centos5]# rpm -ivh yum*.rpm

4、配置yum源(推薦使用的是163的鏡像)

[root@localhost centos5]# vi /etc/yum.repos.d/CenOS-Base.repo

添加以下內容:

# 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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/5/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/5/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/5/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirrors.163.com/centos/5/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http://mirrors.163.com/centos/5/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/5/os/x86_64/RPM-GPG-KEY-CentOS-5

5、清除緩存並下載新的鏡像緩存

[root@localhost centos5]# yum clean all
[root@localhost centos5]# yum makecache

6、測試(查看當前subversion版本與檢查服務器subversion版本)

[root@localhost yum.repos.d]# rpm -qa|grep subversion
subversion-1.6.11-7.el5_6.4
subversion-1.6.11-7.el5_6.4                                                                                                                              [root@localhost yum.repos.d]# yum check-update subversion
Loaded plugins: fastestmirror, katello, product-id, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Loading mirror speeds from cached hostfile

subversion.i386                                                                                    1.6.11-12.el5_10                                                                            base   
subversion.x86_64                                                                                  1.6.11-12.el5_10                                                                            base   
Obsoleting Packages
centos-release.x86_64                                                                              10:5-11.el5.centos                                                                          base   
    redhat-release.x86_64                                                                          5Server-5.8.0.3                                                                              installed
firefox.i386                                                                                      31.3.0-4.el5.centos                                                                          updates 
    firefox.i386                                                                                  3.6.26-1.el5_7                                                                              installed
firefox.x86_64                                                                                    31.3.0-4.el5.centos                                                                          updates 
    firefox.x86_64                                                                                3.6.26-1.el5_7                                                                              installed

7、安裝yum注意問題

根據Linux 的版本號安裝相應的CentOS並引用CentOS版本號對應的CenOS-Base.repo文件,

(1)、如果安裝了CentOS 5的yun,卻引用CentOS6的源yum makecache時就會報錯。

(2)、如果操作系統是RedHat 5,卻安裝 CentOS6 yum會導致安裝時需要手動安裝與升級大量的依賴包。

8、附:CentOS中國鏡像網址

Asia China  Zhejiang University http://mirrors.zju.edu.cn/centos/ 
Asia China Alibaba Cloud Computing http://mirrors.aliyun.com/centos/ 
Asia China Beijing Institute of Technology http://mirror.bit.edu.cn/centos/ 
Asia China BitComm Ltd. http://mirrors.pubyun.com/centos/ 
Asia China CDS China http://mirrors.yun-idc.com/centos/ ftp://mirrors.yun-idc.com/centos/ rsync://mirrors.yun-idc.com/centos/
Asia China China University of Geosciences http://mirrors.cug.edu.cn/centos/ 
Asia China Dalian Neusoft University of Information http://mirrors.neusoft.edu.cn/centos/ ftp://mirrors.neusoft.edu.cn/centos/ 
Asia China Huazhong University of Science and Technology http://mirrors.hust.edu.cn/centos/  rsync://mirrors.hust.edu.cn/centos/
Asia China NetEase http://mirrors.163.com/centos/ 
Asia China Northeastern University, Shenyang Liaoni http://mirror.neu.edu.cn/centos/ 
Asia China Northwest A&F University http://mirrors.nwsuaf.edu.cn/centos/ 
Asia China Qiming College of Huazhong University of Science and Technology http://mirrors.hustunique.com/centos/  rsync://mirrors.hustunique.com/centos/
Asia China Shanghai Jiao Tong University http://ftp.sjtu.edu.cn/centos/ ftp://ftp.sjtu.edu.cn/centos/ 
Asia China Sohu Inc, Beijing P.R. China http://mirrors.sohu.com/centos/ 
Asia China University of Science and Tech of China http://centos.ustc.edu.cn/centos/ 
Asia China - Hong Kong Asia Web Services Ltd. http://mirror.vpshosting.com.hk/pub/linux/centos/ ftp://mirror.vpshosting.com.hk/pub/linux/centos/

CentOS中將DVD作為默認yum源的設置方法  http://www.linuxidc.com/Linux/2015-01/111266.htm

RedHat 6.2 Linux修改yum源免費使用CentOS源 http://www.linuxidc.com/Linux/2013-07/87383.htm

配置EPEL YUM源 http://www.linuxidc.com/Linux/2012-10/71850.htm

Redhat 本地yum源配置 http://www.linuxidc.com/Linux/2012-11/75127.htm

yum的配置文件說明 http://www.linuxidc.com/Linux/2013-04/83298.htm

RedHat 6.1下安裝yum(圖文) http://www.linuxidc.com/Linux/2013-06/86535.htm

YUM 安裝及清理 http://www.linuxidc.com/Linux/2013-07/87163.htm

CentOS 6.4上搭建yum本地源 http://www.linuxidc.com/Linux/2014-07/104533.htm

更多RedHat相關信息見RedHat 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=10

Copyright © Linux教程網 All Rights Reserved