先介绍下我的redhat 6.2的ISO 文件放在sdb5上。

因此我创建两个目录:

mkdir  /tmp/file1

mkdir  /tmp/file2

将sdb5上的redhat 6.2的ISO挂载到/tmp/file1上:

mount   /dev/sdb5   /tmp/file1

redhat 6.2的ISO这时候还不能真接读取,仍需要进一步挂载:

mount -o  --loop /tmp/file1/rhel-server-6.2-x86_64-dvd.iso    /tmp/file2

这时,redhat 6.2的ISO文件才可用。

到/tmp/file2/Packages下,安装顺序安装三个rpm包:

python-kerberos-1.1-6.2.el6.x86_64

yum-3.2.29-22.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64

安装好三个包以后,到/etc/yum.repos.d/下。将配置文件保存一份(备份)。

cp  rhel-source.repo rhel-source.repo.bak  (还有一份文件redhat.repo不是配置文件,因为里面是空的)

将redhat 6.2的ISO放到文件系统上。

mkdir /home/redhatISO

cp  -rp /tmp/file2   /home/redhatISO

在配置文件中进行配置.

vim /etc/yum.repos.d/rhel-source.repo:

[rhel-source]                            #一个标识,可自己定义
name=Red Hat Enterprise Linux $releasever - $basearch - Source      #一个名称而已,可自已定义。
baseurl=file:///home/redhatISO/                  #安装源在本地的路径。安装包中本地何处取得。
enabled=1                             #选项表示源的状态,1表示开启,0表示禁用
gpgcheck=1                            #选项表示对源进行gpg的校验,0为不检查,1为检查
gpgkey=file:///home/redhatISO/RPM-GPG-KEY-redhat-release    #进行gpg校验工具的路径。应该与本地源路径一致。

进行yum的试用:

[root@chen Packages]# yum  install zsh

…………………………………………
======================================================================================
 Package       Arch             Version                   Repository             Size
======================================================================================
Installing:
 zsh           x86_64           4.3.10-4.1.el6            rhel-source           2.1 M
Total download size: 2.1 M
Installed size: 4.8 M
Warning: RPMDB altered outside of yum.
** Found 3 pre-existing rpmdb problem(s), 'yum check' output follows:
PackageKit-0.5.8-19.el6.x86_64 has missing requires of PackageKit-yum = ('0', '0.5.8', '19.el6')
PackageKit-0.5.8-19.el6.x86_64 has missing requires of PackageKit-yum-plugin = ('0', '0.5.8', '19.el6')
rhn-check-1.0.0-73.el6.noarch has missing requires of yum-rhn-plugin >= ('0', '0.9.1', '35')
Installed:
  zsh.x86_64 0:4.3.10-4.1.el6                                                        

Complete!
[root@chen Packages]#