我安裝的linux系統是Oracle Linux,其全稱為Oracle Enterprise Linux。電驢下載:
ed2k://|file|%5BOracle%E5%8F%91%E5%B8%83%E7%9A%84Linux%E7%B3%BB%E7%BB%9F6.0%EF%BC%88%E5%9F%BA%E4%BA%8ERedHat.Enterprise.Linux.6.0%EF%BC%89%5D.OracleLinux-R6-U0-Server-i386-dvd.iso|2829869056|5045d12786a016cd9225038d787f9b44|h=h2ikrphsn6q7ggoeuifoac7pzu3movkq|/下面的方法是我自己實驗成功了的。
1.創建一個存放iso鏡像或光盤內容的目錄
[root@hanxi-workstation hanxi]# mkdir /home/hanxi/yum
並從光盤介質或iso鏡像文件中的所有文件拷貝到剛創建的目錄裡(/home/hanxi/yum)。
如果是光盤可以使用命令:
[root@hanxi-workstation hanxi]# cp -r /media/cdrom /home/hanxi/yum
ps:/media/cdrom是mount光驅的目錄。
我用的是iso鏡像文件,我就直接使用鼠標把文件復制到 /home/hanxi/yum
ps:注意是iso文件裡的所有文件,不是iso文件。
復制完成後是這個樣的,如下圖
2.安裝createrepo
createrepo是配置YUM源的配置工具,檢查當前是否已經安裝createrepo包的安裝情況:
[root@hanxi-workstation hanxi]# rpm -qa |grep createrepo
如果顯示為尚未安裝,則需要執行如下的命令完成安裝:
[root@hanxi-workstation hanxi]# rpm -ivh /home/hanxi/yum/Packages/createrepo-0.9.8-4.el6.noarch.rpm
ps:版本因操作系統的版本有所區別,請查找當前系統的createrepo版本rpm包進行安裝,可以到/home/hanxi/yum/Packages/文件夾下查找,如下圖:
3.創建yum repository的xml-rpm-metadata
執行如下命令:
[root@hanxi-workstation hanxi]# createrepo -g /home/hanxi/yum/Server/repodata/repomd.xml /home/hanxi/yum/Server/
[root@hanxi-workstation hanxi]# createrepo -g /home/hanxi/yum/HighAvailability/repodata/repomd.xml /home/hanxi/yum/HighAvailability/
[root@hanxi-workstation hanxi]# createrepo -g /home/hanxi/yum/LoadBalancer/repodata/repomd.xml /home/hanxi/yum/LoadBalancer/
[root@hanxi-workstation hanxi]# createrepo -g /home/hanxi/yum/ResilientStorage/repodata/repomd.xml /home/hanxi/yum/ResilientStorage/
ps:上面每條命令可能都有段處理時間,注意要等待,如下圖:
執行createrepo命令後系統會自動掃描相關目錄,將rpm包加入到YUM源的數據庫中。