RedHat linux配置yum本地资源
今天安装个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.安装createrepo
createrepo是配置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创建成功。