分类: LINUX
2011-06-06 23:05:36
创建源文件存放的目录
#mkdir /yum/
加载光盘
#mount /dev/cdrom /media
将光盘文件复制到服务器上的源目录
#cp -a /media/* /yum/
新建一个yum源的响应文件
# vi /etc/yum.repos.d/local.repo
内容如下:
[base]
name=linux 6
baseurl=file:///yum
gpgcheck=0
enable=1
修改yum源的地址
# vi /usr/lib/python2.6/site-packages/yum/yumRepo.py
在上面的文件中找到下面这行
remote = url + '/' + relative
将其改为
remote + '/yum' + relative
清除缓存
#yum clean all
配置到这里就完成了,安装个软件做下测试
[root@rhel6-a yum]# yum install samba
Loaded plugins: rhnplugin
This system is not registered with RHN.
RHN support will be disabled.
base | 3.7 kB 00:00 ...
base/primary_db | 2.3 MB 00:00 ...
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package samba.i686 0:3.5.4-68.el6 set to be updated
--> Finished Dependency ResolutionDependencies Resolved
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
samba i686 3.5.4-68.el6 base 5.0 MTransaction Summary
=================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)Total download size: 5.0 M
Installed size: 17 M
Is this ok [y/N]:
大功告成。
当然还可以通过上述方法配置ftp和http的yum源。
======
问题汇总:
1、rhel 6 配置本地源时的错误2、如果首次安装软件包之后,再次安装别的软件包的时候,很可能会发现报错了,错误信息如下:
Error: Cannot retrieve repository metadata (repomd.xml) for repository:
InstallMedia. Please verify its path and try again
其实,rhel6在首次读取改软件仓库之后,会把原本光盘根目录下,也就是一同被你拷贝到软件仓库目录的media.repo复制一份到/etc/yum.repos.d/,而该文件也就是导致本地yum源失效的罪魁祸首。
解决方法:
删除软件仓库中的media.repo
# rm -f /share/rhel/media.repo
或者在/etc/yum.conf增加以下选项
skip_if_unavailable=True
===================================================