您的位置:首页 > 大数据 > 人工智能

Linux下使用Yum管理本地软件包(repository) (转http://www.aiezu.com/Article/Linux_Yum_Packets_admin.aspx)

2010-07-29 16:31 696 查看
在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 system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process  此文来自:http://www.aiezu.com/
Setting up repositories
Setting up repositories
Reading repository metadata in from local files
primary.xml.gz            100% |=========================| 663 kB    00:00
################################################## 2113/2113
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mysql to pack into transaction set.
media://1170972069.396645%232/mysql-5.0.22-2.1.i386.rpm: [Errno 4] IOError:
此文来自:http://www.aiezu.com/
<urlopen error unknown url type: media>
Trying other mirror.
Error: failed to retrieve mysql-5.0.22-2.1.i386.rpm from s
error was [Errno 4] IOError: <urlopen error unknown url type: media>

  答:请确定"/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 system is not registered with RHN.
RHN support will be disabled.
Setting up Group Process
Setting up repositories
Server                    100% |=========================|  951 B    00: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 发表,目前已经被浏览 152 次,评论 0 次;

作者添加了以下标签: LinuxYumRepositoryRhel

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

评论订阅:http://www.aiezu.com/Article/26/Feeds.ashx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐