Redhat 配置YUM 从centos5源更新软件

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目录下,所需时间可能较长.请耐心等待,所以后面会显示一连串数据.
 
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
addons                                                              | 951 B     00:00    
primary.xml.gz                                                      | 201 B     00:00    
base                                                                | 2.1 kB     00:00    
primary.sqlite.bz2                                                  | 1.6 MB     00:34    
update                                                              | 1.9 kB     00:00    
primary.sqlite.bz2                                                  | 463 kB     00:09    
extras                                                              | 1.1 kB     00:00    
primary.xml.gz                                                      | 107 kB     00:01    
extras                                                         325/325
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.3-31.el5.centos.2 set to be updated
filelists.xml.gz                                                    | 194 B     00:00    
filelists.sqlite.bz2                                                | 2.3 MB     00:49    
filelists.sqlite.bz2                                                | 3.3 MB     01:13    
filelists.xml.gz                                                    | 151 kB     00:02    
--> Finished Dependency Resolution
 
Dependencies Resolved
 
===========================================================================================
 Package          Arch            Version                          Repository         Size
===========================================================================================
Installing:
 httpd            i386            2.2.3-31.el5.centos.2            update            1.2 M
 
Transaction Summary
===========================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        
 
Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
httpd-2.2.3-31.el5.centos.2.i386.rpm                                | 1.2 MB     00:26    
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing     : httpd                                             [1/1]
 
Installed: httpd.i386 0:2.2.3-31.el5.centos.2
Complete!                 
  说明可以用yum安装软件了
[root@clinet ~]#
配置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
测试是否能更新软件
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
rhel-debuginfo                                                                                             | 1.3 kB     00:00    
primary.xml.gz                                                                                             | 716 kB     00:00    
rhel-debuginfo                                                 2255/2255
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.3-22.el5 set to be updated
filelists.xml.gz                                                                                           | 2.3 MB     00:00    
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==================================================================================================================================
 Package                    Arch                      Version                           Repository                           Size
==================================================================================================================================
Installing:
 httpd                      i386                      2.2.3-22.el5                      rhel-debuginfo                      1.2 M
 
Transaction Summary
==================================================================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        
 
Total download size: 1.2 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
 Installing     : httpd                                             [1/1]
 
Installed: httpd.i386 0:2.2.3-22.el5
Complete!   
说明测试成功
 
以下是拷贝了KABALA的博文,觉得挺详细,就拿出来供大家参考,博文地址:
http://211.89.225.4:82/gate/big5/blog.cnr.cn/?uid-18-action-viewspace-itemid-8099
yum指令
rpm包的更新
�z查可更新的rpm包
#yum check-update
更新所有的rpm包
#yum update
更新指定的rpm包,如更新kernel和kernel source
#yum update kernel kernel-source
大�模的版本升�,�cyum update不同的是,�B�f的淘汰的包也升�
#yum upgrade
rpm包的安�b和�h除
安�brpm包,如xmms-mp3
#yum install xmms-mp3
�h除rpm包,包括�c�包有倚�性的包
#yum remove licq
注:同�r��提示�h除licq-gnome,licq-qt,licq-text
yum�捍�(/var/cache/yum/)的相�P���
清除�捍嬷�rpm包文件
#yum clean packages
清除�捍嬷�rpm�^文件
#yum clearn headers
清除�捍嬷信f的rpm�^文件
#yum clean oldheaders
清除�捍嬷信f的rpm�^文件和包文件
#yum clearn 或#yum clearn all
注:相��於yum clean packages + yum clean oldheaders
包列表
列出�Y源�熘兴�有可以安�b或更新的rpm包
#yum list
列出�Y源�熘刑囟ǖ目梢园惭b或更新以及已�安�b的rpm包
#yum list mozilla#yum list mozilla*
注:可以在rpm包名中使用匹配符,如列出所有以mozilla�_�^的rpm包
列出�Y源�熘兴�有可以更新的rpm包
#yum list updates
列出已�安�b的所有的rpm包
#yum list installed
列出已�安�b的但是不包含在�Y源�熘械�rpm包
#yum list extras
注:通�^其他�W站下�d安�b的rpm包
rpm包�Y��@示(info��低�list)
列出�Y源�熘兴�有可以安�b或更新的rpm包的�Y�
#yum info
列出�Y源�熘刑囟ǖ目梢园惭b或更新以及已�安�b的rpm包的�Y�
#yum info mozilla#yum info mozilla*
注:可以在rpm包名中使用匹配符,如列出所有以mozilla�_�^的rpm包的�Y�
列出�Y源�熘兴�有可以更新的rpm包的�Y�
#yum info updates
列出已�安�b的所有的rpm包的�Y�
#yum info installed
列出已�安�b的但是不包含在�Y源�熘械�rpm包的�Y�
#yum info extras
注:通�^其他�W站下�d安�b的rpm包的�Y�
搜索rpm包
搜索匹配特定字符的rpm包
#yum search mozilla
注:在rpm包名,包描述等中搜索
搜索有包含特定文件名的rpm包
#yum provides realplay
增加�Y源��
例如:增加rpm.livna.org作�橘Y源��
安�bLivna.org rpms GPG key
#rpm --import http://rpm.livna.org/RPM-LIVNA-GPG-KEY
�z查GPG Key
# rpm -qa gpg-pubkey*
�@示Key�Y�
#rpm -qi gpg-pubkey-a109b1ec-3f6e28d5
(注:如果要�h除Key,使用#rpm -e gpg-pubkey-a109b1ec-3f6e28d5)
yum常用的 命令
# yum install xxx            安�bxxx��w
# yum info xxx                查看xxx��w的�Y�
# yum remove xxx        �h除套�b��w
# yum list                        列出套�b��w
# yum clean                    清除��_和旧的包
# yum provides xxx        以xxx�殛P�I字搜索包(提供的�Y��殛P�I字)
# yum search xxx           搜索套�b��w(以名字�殛P�I字)
# yum groupupdate xxx
# yum grouplist xxx
# yum groupremove xxx
�@三��都是一�M��挝贿M行升� 列表和�h除的操作。。比如 "Mysql Database"就是一���M��同�r操作相�P的所有套�b��w;
# yum update                系�y升�
# yum list available        列出所有升�源上的包;
# yum list updates         列出所有升�源上的可以更新包;
# yum list installed         列出已�安�b的包;
# yun update kernel       升��群耍�
yum常用的源
1) 自�舆x�褡羁斓脑�
由於yum中有的mirror速度是非常慢的,如果yum�x�窳诉@��mirror,�@���r候yum就��非常慢,�Υ耍�可以下�dfastestmirror插件,它��自�舆x�褡羁斓�mirror:
#yum install yum-fastestmirror
配置文件:(一般不用�樱�/etc/yum/pluginconf.d/fastestmirror.conf
你的yum�R像的速度�y���文件:/var/cache/yum/timedhosts.txt
2)使用�D形界面的yum
如果�X得命令行的yum不方便,那�N可以使用�D形化的yumex,�@��看起�砀�方便,因�榭梢宰杂傻剡x�褴��w�}�欤�
#yum install yumex
然後在系�y工具中就可以看到yum extender了。���H上系�y自�У�“添加/�h除程式“也可以���F�D形化的��w安�b,但有些yumex的功能它�]有。

你可能感兴趣的:(redhat,centos,centos,职场,yum,休闲)