Yum可以從眾多軟件包倉庫中搜索軟件的依賴關(guān)系,因此可以減少由于依賴關(guān)系帶來的問題。還有就是我們在使用圖形界面時,在應(yīng)用程序-添加刪除軟件下的瀏覽里是空的。如下圖:
第一種方法:(推薦)
第一步:新建一個文件夾,并把光盤內(nèi)的所有文件復(fù)制到這個文件夾里:
[root@localhost ~]# mkdir /yum
[root@localhost ~]# cp -rvf /misc/cd/* /yum
第二步:備份repodata文件。因為有四個文件夾里都有這個文件,所以都要備份。
[root@localhost ~]# mv /yum/Server/repodata /yum/Server/repodata.bak
[root@localhost ~]# mv /yum/VT/repodata /yum/VT/repodata.bak
[root@localhost ~]# mv /yum/Cluster/repodata /yum/Cluster/repodata.bak
[root@localhost ~]# mv /yum/ClusterStorage/repodata /yum/ClusterStorage/repodata.bak
第三步:安裝工具包:
[root@localhost ~]# rpm -ivh /yum/Server/createrepo-0.4.11-3.el5.noarch.rpm
第四步:生成倉庫數(shù)據(jù)庫:
[root@localhost ~]# createrepo -g /yum/Server/repodata.bak/comps-rhel5-server-core.xml /yum/Server/
[root@localhost ~]# createrepo -g /yum/VT/repodata.bak/comps-rhel5-vt.xml /yum/VT/
[root@localhost ~]# createrepo -g /yum/Cluster/repodata.bak/ /yum/Cluster
[root@localhost ~]# createrepo -g /yum/ClusterStorage/repodata.bak/comps-rhel5-cluster-st.xml /yum/ClusterStorage/
第五步:查看倉庫數(shù)據(jù)文件:
[root@localhost ~]# ls /yum/Server/repodata/
comps-rhel5-server-core.xml //這個文件軟件包組的分類。
filelists.xml.gz other.xml.gz primary.xml.gz //這三個文件為軟件包列表文件。
repomd.xml //這個文件為MD5校驗信息。
在/yum/VT /yum/Cluster /yum/ClusterStorage下面都有這幾個文件,作用和這一樣。如果想更新軟件包,只需把下載完的軟件包放在Server或者其他三個目錄里,再使用第四步重新生成數(shù)據(jù)庫文件即可。
第六步:客戶端配置:主要修改下面紅色的部分:
[root@localhost ~]# cp /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/chenbin.repo
[root@localhost ~]# vi /etc/yum.repos.d/chenbin.repo
[rhel-Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-VT]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=file:///yum/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
第七步:查看:如圖,已經(jīng)出現(xiàn)軟件列表了。

如果在上圖中的編輯里選擇軟件存儲庫,就出現(xiàn)下圖:

如果把這里的勾去掉,再次打開就沒有軟件列表了,同時在/etc/yum.repos.d/chenbin.repo配置文件下的enabled=0。
清除一下yum安裝時的緩存:
[root@localhost ~]# yum clean all
安裝一個軟件試試:
[root@localhost ~]# rpm -ivh /yum/Server/httpd-2.2.3-22.el5.i386.rpm
warning: /yum/Server/httpd-2.2.3-22.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libapr-1.so.0 is needed by httpd-2.2.3-22.el5.i386
libaprutil-1.so.0 is needed by httpd-2.2.3-22.el5.i386
因為依賴關(guān)系,所以不能安裝。用如下命令安裝:
[root@localhost ~]# yum install /yum/Server/httpd-2.2.3-22.el5.i386.rpm