中国网管论坛's Archiver

cnzg_y 发表于 2008-6-9 15:27

centos 中yum的使用

[font=宋体]该文是俺自己在参考了网上的相关内容,自己工作中不断的实践,完善的文档。[/font]
[font=宋体][/font]
[font=宋体]一[/font][font=Times New Roman]. yum[/font][font=宋体]是什么[/font]
[font=Times New Roman]yum = Yellow dog Updater, Modified
[/font][font=宋体]主要功能是更方便的添加[/font][font=Times New Roman]/[/font][font=宋体]删除[/font][font=Times New Roman]/[/font][font=宋体]更新[/font][font=Times New Roman]RPM[/font][font=宋体]包[/font][font=Times New Roman].
[/font][font=宋体]它能自动解决包的倚赖性问题[/font][font=Times New Roman].
[/font][font=宋体]它能便于管理大量系统的更新问题[/font]
[font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]为什么要使用[/font][font=Times New Roman]yum[/font][font=宋体]而不用[/font][font=Times New Roman]apt,[/font][font=宋体]最简单的原因[/font][font=Times New Roman]Centos[/font][font=宋体]自带[/font]
[font=宋体]二[/font][font=Times New Roman]. yum[/font][font=宋体]特点[/font]
[font=Times New Roman]*[/font][font=宋体]可以同时配置多个资源库[/font][font=Times New Roman](Repository)
*[/font][font=宋体]简洁的配置文件[/font][font=Times New Roman](/etc/yum.conf[/font][font=宋体],[/font][font=Times New Roman]/etc/yum.repos.d [/font][font=宋体][size=10.5pt]下的文件[/size][/font][font=Times New Roman])
*[/font][font=宋体]自动解决增加或删除[/font][font=Times New Roman]rpm[/font][font=宋体]包时遇到的倚赖性问题[/font]
[font=Times New Roman]*[/font][font=宋体]使用方便[/font]
[font=Times New Roman]*[/font][font=宋体]保持与[/font][font=Times New Roman]RPM[/font][font=宋体]数据库的一致性[/font]
[font=宋体]三[/font][font=Times New Roman]. yum[/font][font=宋体]安装[/font]
[font=Times New Roman]Centos[/font][font=宋体]自带[/font]
[font=Times New Roman]#rpm -ivh yum-2.4.3-4.el4.centos.noarch.rpm

[/font][font=宋体]四[/font][font=Times New Roman]. yum[/font][font=宋体]配置[/font]
[font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]修改和增加配置文件中的资源库[/font][font=Times New Roman],[/font][font=宋体]加快下载速度和拥有更多可更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=宋体]将[/font][font=Times New Roman]/etc/yum.conf[/font][font=宋体]的内容改改为[/font]
[font=Times New Roman][main][/font]
[font=Times New Roman]cachedir=/var/cache/yum
//[/font][font=宋体]这是缓存目录地址[/font]
[font=Times New Roman]debuglevel=2 //[/font][font=宋体]调试级别[/font][font=Times New Roman],[/font][font=宋体]建议默认,不然[/font][font=Times New Roman]install[/font][font=宋体]时,会好多[/font][font=Times New Roman]error[/font]
[font=Times New Roman]logfile=/var/log/yum.log //[/font][font=宋体]日志文件的位置[/font][font=Times New Roman],install [/font][font=宋体]时,看这里就知道发生了什么[/font]
[font=Times New Roman]pkgpolicy=newest[/font]
[font=Times New Roman]#installonlypkgs=kernel kernel-smp kernel-devel kernel-smp-devel kernel-largesmp kernel-largesmp-devel kernel-hugemem kernel-hugemem-devel[/font]
[font=Times New Roman]//[/font][font=宋体]注销这一行的是不只更新[/font][font=Times New Roman]kernel[/font]
[font=Times New Roman]distroverpkg=centos-release[/font]
[font=Times New Roman]tolerant=1[/font]
[font=Times New Roman]exactarch=1 //[/font][font=宋体]确定是否在[/font][font=Times New Roman]i386[/font][font=宋体]上更新[/font][font=Times New Roman]i686[/font][font=宋体]的软件包[/font][font=Times New Roman],[/font][font=宋体]选[/font][font=Times New Roman]1[/font][font=宋体]的是不更新[/font]
[font=Times New Roman]retries=20[/font]
[font=Times New Roman]obsoletes=1[/font]
[font=Times New Roman]gpgcheck=1[/font]
[font=Times New Roman]plugins=1

[/font]
[font=宋体]把[/font][font=Times New Roman]CentOS-Base.repo [/font][font=宋体](安装[/font][font=Times New Roman]yum[/font][font=宋体]后已有的),做一下备份[/font]
[font=Times New Roman]#cp CentOS-Base.repo CentOS-Base.repo.default[/font]
[font=宋体]在清空整个[/font][font=Times New Roman]CentOS-Base.repo [/font][font=宋体]文件的内容。增加如下内容[/font]
[font=宋体]文件内容在下面的包中。[/font]
[font=宋体]启动[/font][font=Times New Roman]yum [/font]
[font=Times New Roman]#service yum start [/font]
[font=Times New Roman]#chkconfig yum on[/font]
[font=宋体]在导入上面来个站点的[/font][font=Times New Roman]KEY[/font]
[font=Times New Roman]rpm --import [/font][url=http://ftp.hostrino.com/pub/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://ftp.hostrino.com/pub/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]
[font=Times New Roman]rpm --import [url=http://mirror.be10.com/centos/RPM-GPG-KEY-CentOS-4]http://mirror.be10.com/centos/RPM-GPG-KEY-CentOS-4[/url][/font]
[font=Times New Roman]rpm --import [/font][url=http://ftp.daum.net/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://ftp.daum.net/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url][font=Times New Roman] [/font]
[font=Times New Roman]rpm --import [/font][url=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]
[font=Times New Roman]rpm --import [/font][url=http://mirror.tini4u.net/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://mirror.tini4u.net/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]
[font=Times New Roman][/font]
[font=宋体]扩展你的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]wget [/font][url=http://apt.sw.be/redhat/el4/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el4.rf.i386.rpm][font=Times New Roman][color=#0000ff]http://apt.sw.be/redhat/el4/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el4.rf.i386.rpm[/color][/font][/url]
[font=宋体]安装[/font][font=Times New Roman] rpmforge-release-0.3.6-1.el4.rf.i386.rpm[/font]
[font=Times New Roman]# rpm -ivh rpmforge-release-0.3.6-1.el4.rf.i386.rpm[/font]
[font=Times New Roman]# rpm --import [/font][url=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt][font=Times New Roman][color=#0000ff]http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt[/color][/font][/url][font=Times New Roman] [/font]
[font=宋体]在[/font][font=Times New Roman] /etc/yum.repos.d [/font][font=宋体]下将产生这样两个文件[/font]
[font=Times New Roman]mirrors-rpmforge
rpmforge.repo[/font]
[font=Times New Roman]
[color=#ff6600][size=10.5pt][/size][/color][/font]
[font=Times New Roman][/font]
[font=宋体]上面红色字的这部分,有待大家一同研究啊,网上这样写的。但我实现不了。[/font]
[font=宋体]五[/font][font=Times New Roman]. yum[/font][font=宋体]应用[/font]
[font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]当第一次使用[/font][font=Times New Roman]yum[/font][font=宋体]或[/font][font=Times New Roman]yum[/font][font=宋体]资源库有更新时[/font][font=Times New Roman],yum[/font][font=宋体]会自动下载所有所需的[/font][font=Times New Roman]headers[/font][font=宋体]放置于[/font][font=Times New Roman]/var/cache/yum[/font][font=宋体]目录下[/font][font=Times New Roman],[/font][font=宋体]所需时间可能较长[/font][font=Times New Roman].

[/font][font=宋体]检查有哪些可更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum check-update

[/font][font=宋体]安装[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]使[/font][font=Times New Roman]xmms[/font][font=宋体]可以播放[/font][font=Times New Roman]mp3
#yum install xmms-mp3

[/font][font=宋体]安装[/font][font=Times New Roman]mplayer,[/font][font=宋体]同时自动安装相关的软件[/font]
[font=Times New Roman]#yum install mplayer

[/font][font=宋体]删除[/font][font=Times New Roman]licq[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]同时删除与该包有倚赖性的包[/font]
[font=Times New Roman]#yum remove licq
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]同时会提示删除[/font][font=Times New Roman]licq-gnome,licq-qt,licq-text,[/font][font=宋体]非常方便[/font]
[font=宋体]系统更新[/font][font=Times New Roman]([/font][font=宋体]更新所有可以升级的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]包括[/font][font=Times New Roman]kernel)
#yum -y update

[/font][font=宋体]每天定期执行系统更新[/font]
[font=Times New Roman]#chkconfig yum on
#service yum start


[/font][font=宋体]六[/font][font=Times New Roman]. yum[/font][font=宋体]指令详解[/font]
[font=Times New Roman]*rpm[/font][font=宋体]包的更新[/font]
[font=宋体]检查可更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum check-update

[/font][font=宋体]更新所有的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum update

[/font][font=宋体]更新指定的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]如更新[/font][font=Times New Roman]kernel[/font][font=宋体]和[/font][font=Times New Roman]kernel source
#yum update kernel kernel-source

[/font][font=宋体]大规模的版本升级[/font][font=Times New Roman],[/font][font=宋体]与[/font][font=Times New Roman]yum update[/font][font=宋体]不同的是[/font][font=Times New Roman],[/font][font=宋体]连旧的淘汰的包也升级[/font]
[font=Times New Roman]#yum upgrade
*rpm[/font][font=宋体]包的安装和删除[/font]
[font=宋体]安装[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]如[/font][font=Times New Roman]xmms-mp3
#yum install xmms-mp3

[/font][font=宋体]删除[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font][font=Times New Roman],[/font][font=宋体]包括与该包有倚赖性的包[/font]
[font=Times New Roman]#yum remove licq
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]同时会提示删除[/font][font=Times New Roman]licq-gnome,licq-qt,licq-text
*yum[/font][font=宋体]暂存[/font][font=Times New Roman](/var/cache/yum/)[/font][font=宋体]的相关参数[/font]
[font=宋体]清除暂存中[/font][font=Times New Roman]rpm[/font][font=宋体]包文件[/font]
[font=Times New Roman]#yum clean packages

[/font][font=宋体]清除暂存中[/font][font=Times New Roman]rpm[/font][font=宋体]头文件[/font]
[font=Times New Roman]#yum clean headers

[/font][font=宋体]清除暂存中旧的[/font][font=Times New Roman]rpm[/font][font=宋体]头文件[/font]
[font=Times New Roman]#yum clean oldheaders

[/font][font=宋体]清除暂存中旧的[/font][font=Times New Roman]rpm[/font][font=宋体]头文件和包文件[/font]
[font=Times New Roman]#yum clean [/font][font=宋体]或[/font][font=Times New Roman]#yum clean all
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]相当于[/font][font=Times New Roman]yum clean packages + yum clean oldheaders


*rpm[/font][font=宋体]包列表[/font]
[font=宋体]列出资源库中所有可以安装或更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum list

[/font][font=宋体]列出资源库中特定的可以安装或更新以及已经安装的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum list mozilla
#yum list mozilla*
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]可以在[/font][font=Times New Roman]rpm[/font][font=宋体]包名中使用匹配符[/font][font=Times New Roman],[/font][font=宋体]如列出所有以[/font][font=Times New Roman]mozilla[/font][font=宋体]开头的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=宋体]列出资源库中所有可以更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum list updates

[/font][font=宋体]列出已经安装的所有的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum list installed

[/font][font=宋体]列出已经安装的但是不包含在资源库中的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum list extras
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]通过其它网站下载安装的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]*rpm[/font][font=宋体]包信息显示[/font][font=Times New Roman](info[/font][font=宋体]参数同[/font][font=Times New Roman]list)
[/font][font=宋体]列出资源库中所有可以安装或更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]#yum info

[/font][font=宋体]列出资源库中特定的可以安装或更新以及已经安装的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]#yum info mozilla
#yum info mozilla*
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]可以在[/font][font=Times New Roman]rpm[/font][font=宋体]包名中使用匹配符[/font][font=Times New Roman],[/font][font=宋体]如列出所有以[/font][font=Times New Roman]mozilla[/font][font=宋体]开头的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=宋体]列出资源库中所有可以更新的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]#yum info updates

[/font][font=宋体]列出已经安装的所有的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]#yum info installed

[/font][font=宋体]列出已经安装的但是不包含在资源库中的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]#yum info extras
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]通过其它网站下载安装的[/font][font=Times New Roman]rpm[/font][font=宋体]包的信息[/font]
[font=Times New Roman]*[/font][font=宋体]搜索[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=宋体]搜索匹配特定字符的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum search mozilla
[/font][font=宋体]注[/font][font=Times New Roman]:[/font][font=宋体]在[/font][font=Times New Roman]rpm[/font][font=宋体]包名[/font][font=Times New Roman],[/font][font=宋体]包描述等中搜索[/font]
[font=宋体]搜索有包含特定文件名的[/font][font=Times New Roman]rpm[/font][font=宋体]包[/font]
[font=Times New Roman]#yum provides realplay[/font]

[[i] 本帖最后由 cnzg_y 于 2008-6-9 15:31 编辑 [/i]]

isbasic 发表于 2008-6-9 23:05

希望这样的文章以后越多越好阿!!

cnzg_y 发表于 2008-6-10 10:46

CentOS-Base.repo 文件的内容【转自bbs.bitsCN.com】

需要 CentOS-Base.repo 请看附件

[[i] 本帖最后由 cnzg_y 于 2008-8-9 19:07 编辑 [/i]]

iamshiyu 发表于 2008-6-10 10:54

支持一下,我还没有机会用过yum呢

cnzg_y 发表于 2008-6-11 00:47

这个好的经验分享,没人顶啊,而且最重要的文件 CentOS-Base.repo 都贴出来了分享啊,俺自己顶一下

iamshiyu 发表于 2008-6-11 09:13

呵呵,两大版主支持了,你还要怎样啊?:lol
这里潜水的多,发言的少,没办法,这是现状。
也就我这样的菜鸟无知无畏,凑合充充门面。

cnzg_y 发表于 2008-6-11 13:22

感谢两位版主的支持啊,yum 这个只要各位是使用基于rpm包体系的linux发行版,各位会越来越觉得好用哦,现阶段俺自己的感受是,只是它下载的速度可能不用BT、迅雷等慢一些(这个缺点,它下载安装时,你更不用管啊,你可以去干其他的事哦)。还有是各位会说有些包,依靠它也发现不了啊,呵呵这就是这个包所在的开发团队,是否启用(不知道这样叫对不对啊)yum支持,若果启用改了yum支持,你使用yum发现不了啊,这个就是各位的配置问题了。

cnzg_y 发表于 2008-6-16 22:28

[quote]原帖由 [i]cnzg_y[/i] 于 2008-6-10 10:46 发表 [url=http://bbs.bitscn.com/redirect.php?goto=findpost&pid=1680422&ptid=173638][img]http://bbs.bitscn.com/images/common/back.gif[/img][/url]
# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# The mirror system uses the connecting IP address of the client and the
# update status of each  ... [/quote]

若各位想使用最新的centos 5 ,需要把上面的配置文件中的 4 改为 5

还有就是

[font=Times New Roman]rpm --import [/font][url=http://ftp.hostrino.com/pub/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://ftp.hostrino.com/pub/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]
[font=Times New Roman]rpm --import [url=http://mirror.be10.com/centos/RPM-GPG-KEY-CentOS-4]http://mirror.be10.com/centos/RPM-GPG-KEY-CentOS-4[/url][/font]
[font=Times New Roman]rpm --import [/font][url=http://ftp.daum.net/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://ftp.daum.net/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url][font=Times New Roman] [/font]
[font=Times New Roman]rpm --import [/font][url=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]
[font=Times New Roman]rpm --import [/font][url=http://mirror.tini4u.net/centos/RPM-GPG-KEY-CentOS-4][font=Times New Roman][color=#0000ff]http://mirror.tini4u.net/centos/RPM-GPG-KEY-CentOS-4[/color][/font][/url]

后面的 4 也要给位 5 啊 ,呵呵

页: [1]

Powered by Discuz! Archiver 6.1.0  © 1999-2008 bbs.bitsCN.com