YUM

来源:互联网 发布:手机优化软件排名第一 编辑:程序博客网 时间:2024/04/20 23:11
 

YUM 顾名思义,Yellow Dog Updater,Modified.Yum为基于RPM系统做了相同的工作。它提供了一个简单的命令,可用于在首先安装和更新任何其他必要的软件包以满足所需的软件包依赖关系之后,自动化安装或更新一个软件包,类似Debian下apt-get的工具.

 

YUM 的 特点

可以同时配置多个资源库(Repository)
简洁的配置文件(/etc/yum.conf
自动解决增加或删除rpm包时遇到的倚赖性问题
使用方便
保持与RPM数据库的一致性

 

RHEL AS5 可以通过Yum升级系统的功能,但默认 rhel-debuginfo.repo 的设置是从RedHat的Yum源来升级系统,如果您没有购买Redhat的服务,Redhat5后面版本升级是收费,需要key才能升级,那么使用Yum是无法升级的。幸运的是,由于centos是免费的企业版本,可以借用centos yum源更新RHEL AS5系统.

 

配置YUM 从centos5源更新软件

 

[root@clinet ~]# rpm --import http://ftp.twaren.net/Linux/CentOS/RPM-GPG-KEY-CentOS-5

安装那个 ftp.twaren.net 的GPG,也可增加其他资源库,自己选择一个离自己地理位置近点

[root@clinet ~]# rpm -qa gpg-pubkey*

检查GPG Key

gpg-pubkey-e8562897-459f07a4

如果要删除Key,使用以下命令:

[root@clinet ~]# rpm -e gpg-pubkey-e8562897-459f07a4

 

[root@clinet ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/

baseurl 是你的YUM源地址

enabled=0

是否启用这个仓库,1为起用,0为禁用

gpgcheck=1 

设置gpgcheck=1会让yum检查每个下载的RPM的GnuPG签名。这么做是因为你需要适当的GnuPG key注册到您的RPM数据库。可以防止被欺骗,如:非法入侵发行版网站,木马导入软件包,使不知情用户下载

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

GPGKEY 的存放地址

 

以上默认有的,复制添加以下更新点插入到rhel-debuginfo.repo文本里后面

 [base]

name=Red Hat Enterprise Linux $releasever -Base

baseurl=http://ftp.twaren.net/Linux/CentOS/5/os/$basearch/

gpgcheck=1

[update]

name=Red Hat Enterprise Linux $releasever -Updates

baseurl=http://ftp.twaren.net/Linux/CentOS/5/updates/$basearch/

gpgcheck=1

[extras]

name=Red Hat Enterprise Linux $releasever -Extras

baseurl=http://ftp.twaren.net/Linux/CentOS/5/extras/$basearch/

gpgcheck=1

[addons]

name=Red Hat Enterprise Linux $releasever -Addons

baseurl=http://ftp.twaren.net/Linux/CentOS/5/addons/$basearch/

gpgcheck=1

[root@clinet ~]# yum clean all  清除缓存及旧的包

[root@clinet ~]# yum install httpd  测试是否能更新软件

 

注意 : 当第一次使用yum或yum资源库有更新时,yum会自动下载所有所需的headers放置于/var/cache/yum目录下,所需时间可能较长.请耐心等待,所以后面会显示一连串数据.

配置YUM 从本地光盘更新软件

[root@clinet ~]# mkdir /mnt/cdrom

创建挂载点

[root@clinet ~]# mount /dev/cdrom /mnt/cdrom

挂载光盘

mount: block device /dev/cdrom is write-protected, mounting read-only

 

[root@clinet /]# ll /etc/yum.repos.d/

total 4

-rw-r--r-- 1 root root 781 Feb 24 03:19 rhel-debuginfo.repo

[root@clinet /]# cd /etc/yum.repos.d/

[root@clinet yum.repos.d]# cp rhel-debuginfo.repo rhel-debuginfo.repo.bak

拷贝为rhel-debuginfo.repo.bak做备份

[root@clinet yum.repos.d]# ll

total 8

-rw-r--r-- 1 root root 781 Feb 24 03:19 rhel-debuginfo.repo

-rw-r--r-- 1 root root 781 Feb 25 00:34 rhel-debuginfo.repo.bak

[root@clinet yum.repos.d]# vi rhel-debuginfo.repo

编辑rhel-debuginfo.repo,插入以下代码

 

[rhel-debuginfo]

name=Red Hat Enterprise Linux $releasever - $basearch - Debug

baseurl=file:///mnt/cdrom/Server

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

 

其实上面这样设置就已经ok,但是要更新xen.rpm,就更新不到,因为它在/mnt/cdrom/VT下面,为了比较完善,我们修改参数为以下配置

 

[Cluster]
name=Red Hat Enterprise Linux $releasever - $basearch - Cluster
baseurl= file:///mnt/cdrom/Cluster
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[ClusterStorage]
name=Red Hat Enterprise Linux $releasever - $basearch - ClusterStorage
baseurl= file:///mnt/cdrom/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[Server]
name=Red Hat Enterprise Linux $releasever - $basearch - Server
baseurl= file:///mnt/cdrom/Server
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[VT]
name=Red Hat Enterprise Linux $releasever - $basearch - VT
baseurl= file:///mnt/cdrom/VT
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

 

[root@clinet yum.repos.d]# yum clean all

清除缓存及旧的包

Loaded plugins: rhnplugin, security

Cleaning up Everything

[root@clinet yum.repos.d]# yum install httpd

测试是否能更新软件

yum 常用的源

1) 自动选择最快的源

由於yum中有的mirror速度是非常慢的,如果yum选择了这个mirror,这时yum就会非常慢,对此,可以下载fastestmirror插件,它会自动选择最快的mirror:

#yum install yum-fastestmirror

配置文件:(一般不用改)/etc/yum/pluginconf.d/fastestmirror.conf

你的yum镜像的速度测试记录文件:/var/cache/yum/timedhosts.txt

2) 使用图形界面的yum

如果觉得命令行的yum不方便,那么可以使用图形化的yumex,这看起来更方便,因为可以自由地选择软件仓库:

#yum install yumex

然後在系统工具中就可以看到yum extender了。实际上系统自带的“添加/删除程式“也可以实现图形化的软件,但有些yumex的功能它没有。

补充:
yum 本地源的配置与使用

  a:挂载你的光盘到一个目录下:mount -t iso9660 /dev/cdrom /mnt/cdrom

  b:修改你的yum配置文件:编辑 /etc/yum.repos.d/rhel-debuginfo.repo 文件,里面有给

  [rhel-debuginfo]

  name=Red Hat Enterprise Linux $releasever - $basearch - Debug

  baseurl=file:///mnt/cdrom/Server

  enabled=1

  gpgcheck=0

  gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

  主要是baseurl,enabled,gpgcheck字段的配置,本地就是要使用file://absolute path.

  保存并退出。

原创粉丝点击