yum配置及其应用

1.yum简介

Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE、CentOS中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次次下载、安装。yum的宗旨是自动化地升级,安装/移除rpm包,收集rpm包的相 关信息,检查依赖性并自动提示用户解决。yum的关键之处是要有可靠的repository,顾名思义,这是软件的仓库,它可以是http或ftp站点, 也可以是本地软件池,但必须包含rpm的header,header包括了rpm包的各种信息,包括描述,功能,提供的文件,依赖性等.正是收集了这些 header并加以分析,才能自动化地完成余下的任务。

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

3.yum服务器的配置

yum服务器的配置一般分为两种:一是在网络的某一台主机上配置yum服务器,二是配置本地yum。

首先介绍一下网络yum服务器的配置。

1)搭建ftp服务器用来存放各种软件包。

[root@localhost ~]# cd /mnt/cdrom/Server/                                          //切换到光盘目录

[root@localhost Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm             // 安装ftp服务
Preparing...                ########################################### [100%]
package vsftpd-2.0.5-16.el5.i386 is already installed

[root@localhost Server]# service vsftpd start                                      //开启ftp服务器

[root@localhost ftp]# cd /var/ftp/pub

[root@localhost pub]# cp -r /mnt/cdrom/.  ./                                 // 把光盘内容复制到pub目录下

2)配置客户端

[root@station120 ~]# cd /etc/yum.repos.d/                                     //yum配置文件
[root@station120 yum.repos.d]# ll
total 8
-rw-r--r-- 1 root root 254 Aug  4  2009 rhel-debuginfo.repo

[root@station120 yum.repos.d]# vim rhel-debuginfo.repo            

[rhel-server]
name=Red Hat Enterprise Linux server                     //文件仓库的描述
baseurl=ftp://192.168.1.10/pub/Server                   //对应ftp的文件仓库
enabled=1                                                            //启用该文件仓库
gpgcheck=1                                                        //签名检测
gpgkey=ftp://192.168.1.10/pub/RPM-GPG-KEY-redhat-release        //数字证书位置

[rhel-vt]
name=Red Hat Enterprise Linux vt
baseurl=ftp://192.168.1.10/pub/VT
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.1.10/pub/RPM-GPG-KEY-redhat-release
[rhel-cluster]
name=Red Hat Enterprise Linux cluster
baseurl=ftp://192.168.1.10/pub/Cluster
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.1.10/pub/RPM-GPG-KEY-redhat-release
[rhel-clusterstorage]
name=Red Hat Enterprise Linux clusterstorage
baseurl=ftp://192.168.1.10/pub/ClusterStorage
enabled=1
gpgcheck=1
gpgkey=ftp://192.168.1.10/pub/RPM-GPG-KEY-redhat-release

yum客户端配置完毕!在客户端查看有哪些文件仓库

[root@station120 yum.repos.d]# yum repolist
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
rhel-cluster                                                                  | 1.3 kB     00:00    
rhel-cluster/primary                                                          | 6.5 kB     00:00    
rhel-cluster                                                                                   32/32
rhel-clusterstorage                                                           | 1.3 kB     00:00    
rhel-clusterstorage/primary                                                   | 8.8 kB     00:00    
rhel-clusterstorage                                                                            39/39
rhel-server                                                                   | 1.3 kB     00:00    
rhel-server/primary                                                           | 732 kB     00:00    
rhel-server                                                                                2292/2292
rhel-vt                                                                       | 1.3 kB     00:00   

列出所有软件包

[root@station120 yum.repos.d]# yum list

安装软件包

[root@station120 yum.repos.d]# yum install httpd
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.i386 0:2.2.3-31.el5 set to be updated
rhel-cluster/filelists                                                        | 110 kB     00:00    
rhel-clusterstorage/filelists                                                 |  11 kB     00:00    
rhel-server/filelists                                                         | 2.3 MB     00:00    
rhel-vt/filelists                                                             |  26 kB     00:00    
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
Package             Arch               Version                      Repository                 Size

查看已安装的软件包

[root@station120 ~]# yum list installed |grep httpd
This system is not registered with RHN.
RHN support will be disabled.
httpd.i386                                 2.2.3-31.el5                installed

yum可以一次安装多个软件包

[root@station120 ~]# yum install vsftpd telnet-server
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.i386 1:0.17-39.el5 set to be updated
---> Package vsftpd.i386 0:2.0.5-16.el5 set to be updated
--> Finished Dependency Resolution

yum的本地配置

1)编辑配置文件

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

[root@localhost yum.repos.d]# vim rhel-debuginfo.repo

配置内容如下

[rhel-server]
name=Red Hat Enterprise Linux server                                      
baseurl=file:///mnt/cdrom/Server                        //文件仓库为 /mnt/cdrom/Server
enabled=1                                                      //启用该仓库
gpgcheck=1
gpgkey=file:///mnt/cdrom/RPM-GPG-KEY-redhat-release

在本地安装ftp服务器

[root@localhost Server]# yum install vsftpd-2.0.5-16.el5.i386.rpm
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Examining vsftpd-2.0.5-16.el5.i386.rpm: vsftpd-2.0.5-16.el5.i386
Marking vsftpd-2.0.5-16.el5.i386.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.i386 0:2.0.5-16.el5 set to be updated
--> Finished Dependency Resolution

4.yum命令小结

yum list all     //列出所有软件包

yum install  +文件名        //安装某一种软件

yum info   +包名字                 // 查看软件包信息

yum   list   available           //查看未安装的软件包

yum list installed             //擦看已安装的软件包

yum clean all     // 清空信息缓存

yum  remove +包名字      //移除软件包

yum  groupinstall          //安装软件组

yum grouplist               // 列出文件组

yum grouplremove     +组名    //移除软件组

yum  localinstall +包名字  --nogpgcheck    //利用网络yum服务器安装本地软件包

你可能感兴趣的:(yum,软件包,依赖性,yum应用,yum配置)