RHEL中和centos中yum的問題

 

RHEL中和centos中yum的問題
 
RHEL5.0中我們配置YUM的時候可能會遇到下面的問題
RHEL5.35.4中我還沒有遇到這個問題
[root@localhost ~]# yum install samba
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
rhel-debuginfo            100% |=========================| 1.3 kB    00:00    
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 663 kB    00:00    
################################################## 2113/2113
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for samba to pack into transaction set.
media://1170972069.396645%232/samba-3.0.23c-2.i386.rpm: [Errno 4] IOError: <urlopen errorunknown url type: media>
Trying other mirror.
Error: failed to retrieve samba-3.0.23c-2.i386.rpm from rhel-debuginfo
error was [Errno 4] IOError: <urlopen error unknown url type: media>
出現在這種情況應該是我們的YUM數據庫文件和依賴關係沒有弄好,下面我們就分兩部來實現庫文件的生成和生成依賴關係
1:生成庫文件
首先我們先創建一個或者用已有的文件夾來存放庫文件,這裏我們就用/etc/yum這個目錄來存放庫文件
接着我們來執行如下操作來生成庫文件
首先掛載光盤:
[root@localhost ~]# mount /dev/hdc /mnt
mount: block device /dev/hdc is write-protected, mounting read-only
[root@localhost ~]# rpm -ivh /mnt/Server/createrepo-0.4.4-2.fc6.noarch.rpm
warning: /mnt/Server/createrepo-0.4.4-2.fc6.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
   1:createrepo             ########################################### [100%]
[root@localhost ~]# createrepo -o /etc/yum -g /mnt/Server/repodata/comps-rhel5-server-core.xml /mnt/Server/
2113/2113 - zsh-html-4.2.6-1.i386.rpm                                           
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[root@localhost ~]# mount --bind /etc/yum/repodata/ /mnt/Server/repodata/
[root@localhost ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
保存並退出
[root@localhost ~]# yum clean all
[root@localhost ~]# yum makecache
Loading "rhnplugin" plugin
Loading "installonlyn" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up repositories
rhel-debuginfo            100% |=========================| 1.3 kB    00:00    
filelists.xml.gz          100% |=========================| 2.1 MB    00:00    
################################################## 2113/2113
other.xml.gz              100% |=========================| 4.7 MB    00:00    
################################################## 2113/2113
Metadata Cache Created
這樣就可以了我們再來安裝一個軟件測試一下
[root@localhost ~]# yum install samba -y
成功了!
 
---------------------------------------------------------------------------------------------------------------
在CentOS 5.5中的yum 問題
有時候我們的網速比較慢我們希望用本地光盤裏的yum源來安裝一些軟件,以前遇到了一些問題,今天解決了給大家分享一下,
我們查看一下在/etc/yum.repos.d這個目錄中有兩個yum源文件,
[root@apple ~]# ls  /etc/yum.repos.d/
CentOS-Base.repo   CentOS-Media.repo
其中
CentOS-Base.repo是利用網上的源更新的,
CentOS-Media.repo是本地的源,我們就是要在這個上面做操作
我們要用光盤裏的源文件,所以我們要掛載光盤,如下:
[root@apple ~]# mount /dev/hdc  /mnt
在CentOS中光盤的東西跟RHEL是不一樣的,經常用RHEL的朋友要注意了,
[root@apple ~]# ll /mnt/
總計 496
drwxrwxr-x 2  501  501 421888 2010-04-30 CentOS
-rw-r--r-- 1 root root    212 2008-06-15 EULA
-rw-r--r-- 1 root root  18009 2008-06-15 GPL
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
下面我們看一下這個文件的內容
[root@apple ~]# cat /etc/yum.repos.d/CentOS-Media.repo.bak
# CentOS-Media.repo
#
# This repo is used to mount the default locations for a CDROM / DVD on
#  CentOS-5.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c5-media [command]

# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c5-media [command]
 
[c5-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/  
        file:///media/cdrom/         
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@apple ~]#
---------------------------------------------------------------
我們就把配置文件中的
baseurl=file:///media/CentOS/  
        file:///media/cdrom/         
        file:///media/cdrecorder/
這三行改成如下即可:
baseurl=file:///mnt/CentOS/  
       
file:///mnt     
       
file:///mnt
 
再把enable=0  改成 1 表示啓用yum 如下:
enable=1
然後保存退出即可。
然後再用yum來安裝文件我們發現可以用了。
 
 
 
 
 

 

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