RedHat配置YUM 從centos5源與光盤源更新軟件

RedHat配置YUM 從centos5源與光盤源更新軟件

 
YUM顧名思義,Yellow Dog Updater,Modified.Yum爲基於RPM系統做了相同的工作。它提供了一個簡單的命令,可用於在首先安裝和更新任何其他必要的軟件包以滿足所需的軟件包依賴關係之後,自動化安裝或更新一個軟件包,類似Debian下apt-get的工具.
 
YUM的特點
可以同時配置多個資源庫(Repository)
簡潔的配置文件(/etc/yum.conf
自動解決增加或刪除rpm包時遇到的倚賴性問題
使用方便
保持與RPM數據庫的一致性
 
RHEL AS5可以通過Yum升級系統的功能,但默認rhel-debuginfo.repo 的設置是從RedHat的Yum源來升級系統,如果您沒有購買Redhat的服務,Redhat5後面版本升級是收費,需要key才能升級,那麼使用Yum是無法升級的。幸運的是,由於centos是免費的企業版本,可以借用centos yum源更新RHEL AS5系統.
 
配置YUM 從centos5源更新軟件
 
安裝那個ftp.twaren.netGPG,也可增加其他資源庫,自己選擇一個離自己地理位置近點
[root@clinet ~]# rpm -qa gpg-pubkey*
檢查GPG Key
gpg-pubkey-e8562897-459f07a4
如果要刪除Key,使用以下命令:
[root@clinet ~]# rpm -e gpg-pubkey-e8562897-459f07a4
 
[root@clinet ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
baseurl是你的YUM源地址
enabled=0
是否啓用這個倉庫,1爲起用,0爲禁用
gpgcheck=1 
設置gpgcheck=1會讓yum檢查每個下載的RPMGnuPG簽名。這麼做是因爲你需要適當的GnuPG key註冊到您的RPM數據庫。可以防止被欺騙,如:非法***發行版網站,***導入軟件包,使不知情用戶下載
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
GPGKEY 的存放地址
 
以上默認有的,複製添加以下更新點插入到rhel-debuginfo.repo文本里後面
 [base]
name=Red Hat Enterprise Linux $releasever -Base
baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/
gpgcheck=1
[update]
name=Red Hat Enterprise Linux $releasever -Updates
baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/
gpgcheck=1
[extras]
name=Red Hat Enterprise Linux $releasever -Extras
baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/
gpgcheck=1
[addons]
name=Red Hat Enterprise Linux $releasever -Addons
baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/
gpgcheck=1
[root@clinet ~]#yum clean all 清除緩存及舊的包
[root@clinet ~]# yum install httpd 測試是否能更新軟件
 

注意:當第一次使用yumyum資源庫有更新時,yum自動下載所有所需的headers放置於/var/cache/yum目錄下,所需時間可能較長.請耐心等待,所以後面會顯示一連串數據.

配置YUM 從本地光盤更新軟件
[root@clinet ~]# mkdir /mnt/cdrom
創建掛載點
[root@clinet ~]# mount /dev/cdrom /mnt/cdrom
掛載光盤
mount: block device /dev/cdrom is write-protected, mounting read-only
 
[root@clinet /]# ll /etc/yum.repos.d/
total 4
-rw-r--r-- 1 root root 781 Feb 24 03:19 rhel-debuginfo.repo
[root@clinet /]# cd /etc/yum.repos.d/
[root@clinet yum.repos.d]# cp rhel-debuginfo.repo rhel-debuginfo.repo.bak
拷貝爲rhel-debuginfo.repo.bak做備份
[root@clinet yum.repos.d]# ll
total 8
-rw-r--r-- 1 root root 781 Feb 24 03:19 rhel-debuginfo.repo
-rw-r--r-- 1 root root 781 Feb 25 00:34 rhel-debuginfo.repo.bak
[root@clinet yum.repos.d]# vi rhel-debuginfo.repo
編輯rhel-debuginfo.repo,插入以下代碼
 
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
 
其實上面這樣設置就已經ok,但是要更新xen.rpm,就更新不到,因爲它在/mnt/cdrom/VT下面,爲了比較完善,我們修改參數爲以下配置
 
[Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Cluster
baseurl= file:///mnt/cdrom/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage
baseurl= file:///mnt/cdrom/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Server
baseurl= file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux $releasever - $basearch - VT
baseurl= file:///mnt/cdrom/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
 
[root@clinet yum.repos.d]# yum clean all
清除緩存及舊的包
Loaded plugins: rhnplugin, security
Cleaning up Everything
[root@clinet yum.repos.d]# yum install httpd
測試是否能更新軟件
yum常用的源
1) 自動選擇最快的源
由於yum中有的mirror速度是非常慢的,如果yum選擇了這個mirror,這時yum就會非常慢,對此,可以下載fastestmirror插件,它會自動選擇最快的mirror:
#yum install yum-fastestmirror
配置文件:(一般不用改)/etc/yum/pluginconf.d/fastestmirror.conf
你的yum鏡像的速度測試記錄文件:/var/cache/yum/timedhosts.txt
2)使用圖形界面的yum
如果覺得命令行的yum不方便,那麼可以使用圖形化的yumex,這看起來更方便,因爲可以自由地選擇軟件倉庫:
#yum install yumex
然後在系統工具中就可以看到yum extender了。實際上系統自帶的“添加/刪除程式“也可以實現圖形化的軟件,但有些yumex的功能它沒有。

補充:
yum本地源的配置與使用

  a:掛載你的光盤到一個目錄下:mount -t iso9660 /dev/cdrom /mnt/cdrom

  b:修改你的yum配置文件:編輯 /etc/yum.repos.d/rhel-debuginfo.repo 文件,裏面有給

  [rhel-debuginfo]

  name=Red Hat Enterprise Linux $releasever - $basearch - Debug

  baseurl=file:///mnt/cdrom/Server

  enabled=1

  gpgcheck=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

  主要是baseurl,enabled,gpgcheck字段的配置,本地就是要使用file://absolute path.

  保存並退出。

  c:yum update

  這裏有想必大家有個疑問,光盤放進光驅後,如果能識別的話就已經自動掛載到了/media下爲什麼我們還要費事手動掛載呢?這個倒是必須的,因爲你不掛載的話你yum需要的repodata文件是沒有任何東西的,因爲yum要去讀這個文件纔會自動給你解決依賴關係的。

還有一個想要與大家一起學習的就是,在你沒有盤,只有iso文件時怎麼辦?很簡單,一條命令解決 mount -o loop /xx/xx/xxx.iso /mnt/cdrom你可以繼續了。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章