linux 添加repository,Linux下使用Yum管理本地软件包(repository)

在Linux系统的维护中,Linux软件包之间的依赖性是一件令人十分头痛的事情。比如你要安装软件包A,但是安装的时候提示你在安装A前得先安装软件包B;而当你去安装软件包B时,又提示你得先安装C库... 为了解决此问题,我们得使用Linxu下的yum(Yellow dog Updater,Modified) 工具。yum工具能根据repository(软件仓库)中rpm包的各种header信息,自动安装依赖的包,解决依赖性问题。在linux下使用yum的添加/删除/更改rpm包十分方便!此文来自:http://www.aiezu.com/

下面是linux下一个简单的yum配置和使用过程:

1. 实验环境

操作系统:Red Hat Enterprise Linux AS 5

内核版本:2.6.18-8.el5

CPU构架:i386 SMP

附件软件:Red Hat Enterprise Linux AS 5 DVD ISO文件

2. 在linux下安装yum并建立repository(软件仓库)

#在linux系统下挂载rhel 5.0 dvd iso文件

mkdir -p /mnt/iso

mount -o loop /opt/rhel5.0.iso/mnt/iso

#在linux系统下安装yum,createrepo包

rpm -ivh /mnt/ISO/Server/yum-3.0.1-5.el5.noarch.rpm

rpm -ivh /mnt/ISO/Server/yum-metadata-parser-1.0-8.fc6.i386.rpm

rpm -ivh /mnt/ISO/Server/yum-rhn-plugin-0.4.3-1.el5.noarch.rpm

rpm -ivh /mnt/ISO/Server/yum-updatesd-3.0.1-5.el5.noarch.rpm

rpm -ivh /mnt/ISO/Server/createrepo-0.4.4-2.fc6.noarch.rpm

#将挂载的iso中的文件复制到/opt/rhel5.0目录中

mkdir /opt/rhel5.0

cp -R /mnt/ISO/* /opt/rhel5.0

#重新生成repository(软件仓库)相关文件,生成的文件在当前目录的“repodata”文件夹下。

cd /opt/rhel5.0/Server/

rm -rf repodata

createrepo -g /mnt/ISO/Server/repodata/comps-rhel5-server-core.xml ./

3. 在linux配置yum在/etc/yum.repos.d/目录下建立一个后缀为.repo的配置文件,如:rhel_yum.repo(该目录下的其他文件可以删除),rhel_yum.repo内容如下:此文来自:http://www.aiezu.com/

[Server]

name=Server

baseurl=file:///opt/rhel5.0/Server/

#注意baseurl指向我们的repository(软件仓库)/opt/rhel5.0/Server目录

enable=1

gpgcheck=0

此文来自:http://www.aiezu.com/

4. 测试rhel5.0 linux下的yum

#清除yum设置缓存

yum clean all

#查看已安装的和未安装的软件包组

yum grouplist

#安装Web Server包组

yum groupinstall"Web Server"

#查看组信息

yum groupinfo"Web Server"

此文来自:http://www.aiezu.com/

#删除"MySQL Database"

yum groupremove"MySQL Database"

#升级"MySQL Database"

yum groupupdate"MySQL Database"

5. linux下yum安装的常见问题

①.问:为什么要把挂载的ISO镜像中的文件复制到本地磁盘上,而不直接在挂载的iso文件系统中使用?

答:因为我们必须重新生成repository的相关配置文件,而挂载的iso文件系统是不可写的,所以必须复制到本地磁盘中去。

②. 问:当我们配置好后执行 "yum groupinstall 'MySQL Database' " 安装时报如下错误,是怎么回事?

yum groupinstall"MySQL Database"

Loading"installonlyn"plugin

Loading"rhnplugin"plugin

This systemisnotregistered with RHN.

RHN support will be disabled.

Setting up Group Process  此文来自:http://www.aiezu.com/

Setting up repositories

Setting up repositories

Reading repository metadatainfromlocal files

primary.xml.gz100% |=========================|663kB00:00

################################################## 2113/2113

Resolving Dependencies

--> Populating transaction set with selected packages. Please wait.

---> Downloading headerformysql to pack into transaction set.

media://1170972069.396645%232/mysql-5.0.22-2.1.i386.rpm: [Errno4] IOError:

此文来自:http://www.aiezu.com/

Trying other mirror.

Error: failed to retrieve mysql-5.0.22-2.1.i386.rpmfroms

error was [Errno4] IOError: 

答:请确定"/etc/yum.repos.d/rhel_yum.repo"文件中的"baseurl"指向的不是挂载的iso文件系统路径,而是本地磁盘文件系统路径,如此文的第三步的中的第三行。并且确定使用了第二步的第九行重新生成了repository配置文件。其实"media://1170972069.396645#1"就是rhel 5.0 dvd iso 中的Server/repodata/repomd.xml文件的配置值。此文来自:http://www.aiezu.com/

③. 问:为什么我执行"yum grouplist"命令后没有列出任何包组信息?如下:

#yum grouplist

Loading"installonlyn"plugin

Loading"rhnplugin"plugin

This systemisnotregistered with RHN.

RHN support will be disabled.

Setting up Group Process

Setting up repositories

Server100% |=========================|951B00:00

Done

答:请确定执行了createrepo命令重新生成repository配置文件,并且命令带了 "-g"选项,如第二步第19行所示。rhel 5.0 dvd iso中的"Server/repodata/comps-rhel5-serer-core.xml"即包含了rpm包的分组信息。此文来自:http://www.aiezu.com/

好了,Linux下使用Yum管理本地软件包就写到此了,有什么问题欢迎随时给我留言。

此文章由 Admin 于 2010-06-29 22:51:29 编辑

本日志由 Admin 于 2010-06-26 18:29:14 发表,目前已经被浏览 1421 次,评论 5 次;

引用通告:http://www.aiezu.com/Article/26/Trackback.ashx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值