RedHat Linux RHEL6配置本地YUM源

http://www.cnblogs.com/kerrycode/p/4723637.htmlhtml

YUM是Yellow dog Updater Modified的簡稱,起初是由yellow dog這一發行版的開發者Terra Soft研發,用python寫成,那時還叫作yup(yellow dog updater),後經杜克大學的Linux@Duke開發團隊進行改進,遂有此名。yum的宗旨是自動化地升級,安裝/移除rpm包,收集rpm包的相關信息,檢查依賴性並自動提示用戶解決。yum的關鍵之處是要有可靠的repository,顧名思義,這是軟件的倉庫,它能夠是http或ftp站點,也能夠是本地軟件池,但必須包含rpm的header, header包括了rpm包的各類信息,包括描述,功能,提供的文件,依賴性等.正是收集了這些 header並加以分析,才能自動化地完成餘下的任務。python

若是體驗過rpm安裝痛苦的人,我相信其確定百分之百選擇yum替代rpm。使用yum很是方便。若是要使用rpm則必須配置repository(軟件倉庫),因爲RHEL的yum在線更新是收費的,若是沒有註冊的話不能使用,若是要使用yum安裝一些包,則須要配置本地的YUM源。下面介紹一下如何配置,下文以Red Hat Enterprise Linux Server release 6.6爲實驗場景。可能不一樣版本的Linux稍有差異。緩存

一:掛載本地光盤到系統服務器

若是服務器是虛擬機,能夠經過vSphere Client進入控制平臺,在「編輯設置」——>「硬件」——>「CD/DVD驅動器」裏指定操做系統的ISO鏡像文件。若是是物理機,則須要進入機房找到服務器,在光驅裏面放入安裝光盤。這個相對而言比較麻煩,因此通常最好複製光盤文件到本地硬盤。url

 

方法1:光驅掛載鏡像spa

[root@getlnx06 ~]# mkdir /mnt/cdrom
[root@getlnx06 ~]# mount -t iso9660 /dev/cdrom  /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@getlnx06 ~]#

方式2:複製光盤文件操作系統

文件/tmp/rehl6.tar.gz是從光盤打包複製過來的,順便解壓到到指定目錄/mnt/cdromcode

[root@localhost ~]# mkdir /mnt/cdrom/
[root@localhost ~]tar zxvf /tmp/rehl6.tar.gz -C /mnt/cdrom/

二:配置本地YUM源orm

[root@localhost ~]#  cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
redhat.repo   rhel-source.repo
[root@localhost yum.repos.d]touch rhel-media.repo
[root@localhost yum.repos.d]# vi rhel-media.repo
[media]
name=Red Hat Enterprise Linux 6.6                               
baseurl=file:///mnt/cdrom                                        
enabled=1                                                        
gpgcheck=1                                                       
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release 

清除原有緩存htm

[root@localhost ~]# yum clean all
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: media
Cleaning up Everything

獲取yum列表

驗證yum配置是否成功

[root@localhost ~]# yum makecache
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
media                                                                    | 4.1 kB     00:00 ...
media/group_gz                                                           | 211 kB     00:00 ...
media/filelists_db                                                       | 3.3 MB     00:00 ...
media/primary_db                                                         | 3.1 MB     00:00 ...
media/other_db                                                           | 1.4 MB     00:00 ...
Metadata Cache Created
[root@localhost ~]#

image

 

驗證yum配置是否成功
[root@localhost ~]# yum grouplist | grep Server
   Network Infrastructure Server
   Server Platform
   Web Server
   Backup Server
   Directory Server
   Identity Management Server
   Network Storage Server
   Print Server
   Server Platform Development

 

小問題:

在yum配置文件裏,若是忘記添加添加yum源的名字,則有可能報下面錯誤。

[root@getlnx06 yum.repos.d]# yum clean all

Loaded plugins: product-id, security, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Error: File contains no section headers.

file: file:///etc/yum.repos.d/rhel-media.repo, line: 1

'name=Red Hat Enterprise Linux 6.6 \n'

clip_image001

相關文章
相關標籤/搜索