今天安裝個linux平台的oracle數據庫,在oracle檢測的時候發現有些系統補丁包沒有安裝,手動rpm安裝報有些關聯包也沒有安裝,想想如果一個一個rpm的話累死人了要,所以想起用yum來進行安裝,但是系統上的yum沒有配置好,上網辛勤的搜索了下經過九曲十八彎最後終於搞定,現在和大家分享下具體過程。
1.創建個目錄mkdir /var/yum
並從光盤介質中把Server目錄下的所有文件拷貝到剛創建的目錄裡(/var/yum)。
cp -r /media/cdrom /var/yum
ps:/media/cdrom是mount光驅的目錄
2.安裝createrepocreaterepo是配置YUM源的配置工具,檢查當前是否已經安裝createrepo包的安裝情況:
# rpm -qa |grep createrepo
如果顯示為尚未安裝,則需要執行如下的命令完成安裝:
# rpm -ivh /media/cdrom/Server/createrepo-0.4.4-2.fc6.noarch.rpm
ps:版本因操作系統的版本有所區別,請查找當前系統的createrepo版本rpm包進行安裝
3.創建yum repository的xml-rpm-metadata執行如下命令:
# createrepo -g /var/yum/Server/repodata/comps-rhel5-server-core.xml /var/yum/Server/
# createrepo -g /var/yum/VT/repodata/comps-rhel5-vt.xml /var/yum/VT/
# createrepo -g /var/yum/Cluster/repodata/comps-rhel5-cluster.xml /var/yum/Cluster/
# createrepo -g /var/yum/ClusterStorage/repodata/comps-rhel5-cluster-st.xml /var/yum/ClusterStorage/
執行createrepo命令後系統會自動掃描相關目錄,將rpm包加入到YUM源的數據庫中。
4.創建本地yum客戶端的repo文件配置使用本地yum repository:
# cd /etc/yum.repos.d/
# vim local.repo (名字可以隨便起,但是要以.repo為後綴)
接下來在文件中添加如下內容後保存:
[local] #(yum塊區域)
name=aaa # (名字可以隨便起)
baseurl=file:///var/yum/Server #(搜索路徑,必須指向你本機的yum源路徑)
gpgcheck=0 #(gpgcheck是gpg驗證是否開啟的選項,1是開啟,0是不開啟,一般情況可以關掉)
enabled=1 #(是否啟用,0為不啟用,1為啟用,過沒這一項,就是啟用)
[VT]
name=VT
baseurl=file:///var/yum/VT
gpgcheck=0
[Cluster]
name= Cluster
baseurl=file:///var/yum/Cluster
gpgcheck=0
[CS]
name= ClusterStorage
baseurl=file:///var/yum/ClusterStorage
gpgcheck=0
5.測試使用yum來安裝軟件包[root@linux-a yum.repos.d]# yum install samba
Loading "installonlyn" plugin
Loading "rhnplugin" plugin
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Setting up repositories
CS 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
VT 100% |=========================| 1.1 kB 00:00
Cluster 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 3.9 kB 00:00
################################################## 32/32
primary.xml.gz 100% |=========================| 727 kB 00:00
################################################## 2113/2113
primary.xml.gz 100% |=========================| 5.8 kB 00:00
################################################## 31/31
primary.xml.gz 100% |=========================| 5.6 kB 00:00
################################################## 32/32
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for samba to pack into transaction set.
samba-3.0.23c-2.i386.rpm 100% |=========================| 108 kB 00:00
---> Package samba.i386 0:3.0.23c-2 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
samba i386 3.0.23c-2 base 16 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 16 M
Is this ok [y/N]:
大功告成,本地yum repository創建成功。