RHEL中和centos中yum的问题
 
RHEL5.0 中我们配置YUM 的时候可能会遇到下面的问题
RHEL5.3 5.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 error unknown 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来安装文件我们发现可以用了。