23. 文件系统——使用yum安装软件包

一、yum命令的基本安装功能

[[email protected] ~]# man yum

command is one of:

* install package1 [package2] [...]:  install + 包名

yum -y: 安装时自动回答为yes

* reinstall package1 [package2] [...]: 重新安装

*** 补充rmp命令:rpm -ql + 包名 : 查询包安装生成的文件清单

rpm -qf + /path/to/file_name: 查询某文件是由哪个软件包生成的

* provides | whatprovides feature1 [feature2] [...]

使用yum来查询软件包生成哪些文件,以及文件是由哪个软件包生成的。

* update [package1] [package2] [...]: 升级版本,可加多个包

* update-to [package1] [package2] [...]: 指定升级到哪个版本

* downgrade package1 [package2] [...] : 降级

* check-update: 安装前检查有哪些可以升级的软件包

* upgrade [package1] [package2] [...]

* upgrade-to [package1] [package2] [...]

这两个命令已经被update取代了

* remove | erase package1 [package2] [...]

清除软件包:使用yum来清除包会同时清除它被依赖的包

* search string1 [string2] [...] : 只记得部分字符,可以进行模糊查询

* groupinstall group1 [group2] [...] :组安装:

1) 针对RHEL 6:

Development tools + Server Platform Development + Desktop Platform Development

2) 针对RHEL 5:

Development tools + development libraries

安装了这些这些组之后,就可以编译rpm包了,即将源码制作成二进制格式包

* groupupdate group1 [group2] [...] 升级组

* groupremove group1 [group2] [...] 移除组

* localinstall yum除了可以自动安装外,也可以将软件包下载到本地,然后手动安装

1)RHEL 6:

统一使用yum install 来安装即可

2)RHEL 5:

需要使用yum localinstall 来安装,同样手动升级可以使用yum localupdate,RHEL6处于兼容性需求,也支持这样的用法。

yum安装软件包最大的优势在于可以自动解决依赖关系

-- nogpgcheck :

对比rpm包,yum即使使用了localinstall,也会检查软件包的来源合法性,如果密钥无法匹配,则下载到本地的软件包也无法使用yum安装,故可以使用长选项 --nogpgcheck来避免检查

* history : 查看此前的安装卸载等操作历史

二、yum命令安装实例演示

/*-------- (1) 基本安装 --------*/

[[email protected] ~]# yum install bind-chroot

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64 already installed and latest version
Nothing to do
# 已经安装了最新版,无需安装

现在先卸载这个软件包

[[email protected] ~]# rpm -e bind-chroot

grep: /etc/sysconfig/named: No such file or directory

[[email protected] ~]# rpm -e bind-chroot --force

rpm: only installation, upgrading, rmsource and rmspec may be forced

[[email protected] ~]# rpm -e bind-chroot

error: package bind-chroot is not installed

[[email protected] ~]# yum install bind-chroot

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Processing Dependency: bind = 32:9.8.2-0.17.rc1.el6_4.6 for package: 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Finished Dependency Resolution
#依赖关系自动解决
 
Dependencies Resolved
 
=============================================================================
 Package                  Arch                Version                                  Repository         Size
==============================================================================
Installing:
 bind-chroot              x86_64              32:9.8.2-0.17.rc1.el6_4.6                base               71 k
Installing for dependencies:
 bind                     x86_64              32:9.8.2-0.17.rc1.el6_4.6                base              4.0 M
 
Transaction Summary
=========================================================================
Install       2 Package(s)
 
Total download size: 4.0 M
Installed size: 7.3 M
Is this ok [y/N]: 
 
# 输入y表示安装,N表示不安装,默认为不安装,yum可以使用-y自动回答安装
 
Is this ok [y/N]: y
Downloading Packages:
--------------------------------------------------------------------------------
Total                                                                           42 MB/s | 4.0 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
  Installing : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64                                                       1/2 
  Installing : 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64                                                2/2 
  Verifying  : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64                                                       1/2 
  Verifying  : 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64                                                2/2 
 
Installed:
  bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6                                                                 
 
Dependency Installed:
  bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6                                                                        
 
Complete!

/*-------- (2) 重新安装 --------*/

[[email protected] ~]# yum install bind

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Package 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64 already installed and latest version
Nothing to do
# 提示已经安装过了

[[email protected] ~]# yum reinstall bind

# 不论是否安装,都会重新安装一遍
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Reinstall Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be reinstalled
--> Finished Dependency Resolution
 
Dependencies Resolved
 
============================================================================
 Package             Arch                  Version                                   Repository           Size
===========================================================================
Reinstalling:
 bind                x86_64                32:9.8.2-0.17.rc1.el6_4.6                 base                4.0 M
 
Transaction Summary
===============================================================================
Reinstall     1 Package(s)
 
Total download size: 4.0 M
Installed size: 7.3 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64                                                       1/1 
  Verifying  : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64                                                       1/1 
 
Installed:
  bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6                                                                        
 
Complete!

/*-------- (3) 卸载软件包 --------*/

[[email protected] ~]# yum remove bind

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be erased
--> Processing Dependency: bind = 32:9.8.2-0.17.rc1.el6_4.6 for package: 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Running transaction check
---> Package bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                  Arch                Version                                 Repository          Size
==============================================================================
Removing:
 bind                     x86_64              32:9.8.2-0.17.rc1.el6_4.6               @base              7.3 M
Removing for dependencies:
 bind-chroot              x86_64              32:9.8.2-0.17.rc1.el6_4.6               @base              0.0  
 # 清除bind的同时会清除bind-chroot,因为bind-chroot是依赖于bind的
 
Transaction Summary
==============================================================================
Remove        2 Package(s)
 
Installed size: 7.3 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64                                            1/2 
  Erasing    : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64            2/2 
warning: /etc/sysconfig/named saved as /etc/sysconfig/named.rpmsave
  Verifying  : 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64                                                       1/2 
  Verifying  : 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64                                                2/2 
 
Removed:
  bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6                                                                        
 
Dependency Removed:
  bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6                                                                 
 
Complete!

/*-------- (4)软件包安装信息查询 --------*/

[[email protected] ~]# rpm -qf /etc/inittab

initscripts-9.03.40-2.el6.centos.x86_64

[[email protected] ~]# rpm -qf /etc/fstab

setup-2.8.14-20.el6_4.1.noarch

[[email protected] ~]# yum provides /etc/fstab

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files
# 此包生成了/etc/fstab
Repo        : base
Matched from:
Filename    : /etc/fstab
  
setup-2.8.14-20.el6_4.1.noarch : A set of system configuration and setup files
Repo        : installed
Matched from:
Other       : Provides-match: /etc/fstab

[[email protected] ~]# yum provides /etc/named.conf

#也可以显示没有安装的文件
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64 : The Berkeley Internet Name Domain (BIND) DNS (Domain Name System)
                                      : server
# 这个包之前被卸载了,这里显示的是服务器仓库上的包
Repo        : base
Matched from:
Filename    : /etc/named.conf

/*-------- (5) 模糊匹配查询 --------*/

[[email protected] ~]# yum search init

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
==============================N/S Matched: init ===============================
initscripts.x86_64 : The inittab file and the /etc/init.d scripts
iscsi-initiator-utils-devel.x86_64 : Development files for 
...
upstart.x86_64 : An event-driven init system
xhtml1-dtds.noarch : XHTML 1.0 document type definitions
xorg-x11-xinit-session.x86_64 : Display manager support for ~/.xsession and ~/.Xclients
 
  Name and summary matches only, use "search all" for everything.

/*-------- (6) 安装包组 --------*/

通常安装开发环境,为避免依赖关系,通常需要安装三个组:Development tools; Server Platform Development; Desktop Platform Development

[[email protected] ~]# yum grouplist

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Group Process
Loading mirror speeds from cached hostfile
base/group_gz                                                                | 220 kB     00:00 ... 
Installed Groups:
   Additional Development
   Base
   Debugging Tools
   ...
   Web Server
   X Window System
Installed Language Groups:
   Arabic Support [ar]
   ...
   Venda Support [ve]
Available Groups:
   Backup Client
   ...
   iSCSI Storage Client
Available Language Groups:
   Afrikaans Support [af]
  ...
   Zulu Support [zu]
Done

[[email protected]~]#yum -y groupinstall "Development tools" "Server Platform Development" "Desktop Platform Development"

 
...
 pixman-devel              x86_64         0.26.2-5.el6_4                             base          18 k
 ppl                       x86_64         0.10.2-11.el6                              base         1.3 M
 systemtap-client            x86_64         2.3-3.el6                                  base         3.4 M
 systemtap-devel            x86_64         2.3-3.el6                                  base         1.4 M
 xorg-x11-proto-devel       noarch         7.6-25.el6                                 base         274 k
 yajl                      x86_64         1.0.7-3.el6                                base          27 k
 
Transaction Summary
==============================================================================
Install     115 Package(s)
 
Total download size: 123 M
Installed size: 404 M
...                         
  systemtap-devel.x86_64 0:2.3-3.el6              xorg-x11-proto-devel.noarch 0:7.6-25.el6                    
  yajl.x86_64 0:1.0.7-3.el6                      
 
Complete!

/*-------- (7) 通过yum下载到本地,然后手动安装软件包 --------*/

[[email protected] ~]# cd /media/cdrom/Packages/

[[email protected] Packages]# yum install bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm

# 这个包已经下载到本地了,因此不再从服务器下载
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Examining bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm: 32:bind-9.8.2-0.17.rc1.el6_4.6.x86_64
Marking bind-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=========================================================================================
 Package     Arch          Version                            Repository                                  Size
==========================================================================================
Installing:
 bind        x86_64        32:9.8.2-0.17.rc1.el6_4.6          /bind-9.8.2-0.17.rc1.el6_4.6.x86_64        7.3 M
 
Transaction Summary
==========================================================================================
Install       1 Package(s)
 
Total size: 7.3 M
Installed size: 7.3 M
Is this ok [y/N]: N

[[email protected] Packages]# yum localinstall bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Local Package Process
Examining bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm: 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64
Marking bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package bind-chroot.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Processing Dependency: bind = 32:9.8.2-0.17.rc1.el6_4.6 for package: 32:bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.17.rc1.el6_4.6 will be installed
--> Finished Dependency Resolution
 
# 可以看到使用localinstall 也会自动解决依赖关系
 
Dependencies Resolved
 
=========================================================================================
 Package         Arch       Version                       Repository                                      Size
==========================================================================================
Installing:
 bind-chroot     x86_64     32:9.8.2-0.17.rc1.el6_4.6     /bind-chroot-9.8.2-0.17.rc1.el6_4.6.x86_64     0.0  
Installing for dependencies:
 bind            x86_64     32:9.8.2-0.17.rc1.el6_4.6     base                                   4.0 M
 
Transaction Summary
==========================================================================================
Install       2 Package(s)
 
Total download size: 4.0 M
Installed size: 7.3 M
Is this ok [y/N]: n
Exiting on user Command

/*-------- (8) 查看yum命令的历史记录 --------*/

[[email protected] ~]# yum history

Loaded plugins: fastestmirror, refresh-packagekit, security
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     5 | root <root>              | 2014-08-17 06:53 | Install        |  115   
     4 | root <root>              | 2014-08-17 06:37 | Erase          |    2 EE
     3 | root <root>              | 2014-08-17 06:20 | Reinstall      |    1   
     2 | root <root>              | 2014-08-17 06:16 | Install        |    2  <
     1 | System <unset>           | 2014-07-09 21:22 | Install        | 1205 > 
history list
时间: 2024-10-10 16:46:37

23. 文件系统——使用yum安装软件包的相关文章

yum安装软件包错误 HTTP Error 404 - Not Found Trying other mirror.

Fedora下yum安装软件包时提示标题所示的错误信息,原因估计是yum查找软件包依赖时使用的是过时的缓存,清空更新之后,再次安装软件,问题消失, 具体指令如下: # yum clean all # yum update

yum安装软件包时出现Transaction Check Error:错误的解决方法

[[email protected] ~]# yum install ipa-server Transaction Check Error:  file /usr/share/man/man3/XML::SAX::Base.3pm.gz conflicts between attempted installs of perl-XML-SAX-0.96-7.el6.noarch and perl-XML-SAX-Base-1.04-1.el6.rf.noarch  file /usr/share/

查看 yum 安装软件包的路径

#yum install subversion #rpm -qa | grep subversionsubversion-1.6.11-10.el6_5.x86_64 # rpm -ql subversion-1.6.11-10.el6_5.x86_64 ... /usr/share/doc/subversion-1.6.11/usr/share/doc/subversion-1.6.11/BUGS/usr/share/doc/subversion-1.6.11/CHANGES ... rpm

解决:yum安装软件包Transaction Check Error错误

解决:yum安装软件包Transaction Check Error错误 yum(YellowdogUpdater,Modified)是软件包管理工具,就不多说了.错误产生的环境:OS:CentOS release 6.5 (Final)uname -r:2.6.32-431.el6.x86_64 在yum安装gnaglia时遇到的,具体错误如下: Transaction Check Error: Transaction Check Error:   file /usr/lib64/gangli

yum安装软件包提示Error Downloading Packages解决方法

使用 yum install hmaccalc.x86_64 安装软件包时,提示:Error Downloading Packages 解决方法: 1.清理本地yum缓存 执行:yum clean all 2.查看软件包列表 执行:yum list 注意:如果查询不到软件包列表,查看yum源是否配置正确.

22.文件系统——使用yum查看软件包

一.yum命令的基本查询功能 yum有很多子命令,它的基本格式是: yum SubCommand File_Name | Package_Name 可以使用man来查看一下yum的帮助信息: [[email protected] ~]# man yum command is one of: * repolist [all|enabled|disabled]:显示当前使用的仓 * list [...] : 显示相关程序包,list子命令还有很多选项可用: yum list [all | glob_

rpm | yum 安装软件包时key过期

1.问题: yum -y install docker-io Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * epel: mirrors.tuna.tsinghua.edu.cn * local: Resolving Dependencies --> Running transact

转:CentOS系统yum源配置修改、yum安装软件包源码包出错解决办法!

yum安装包时报错: Could not retrieve mirrorlist http://mirrorlist.repoforge.org/el6/mirrors-rpmforge error was 14: PYCURL ERROR 7 - "couldn't connect to host" http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7

yum安装于卸载软件常见命令

1.使用yum安装和卸载软件,有个前提是yum安装的软件包都是rpm格式的. 安装的命令是,yuminstall ~,yum会查询数据库,有无这一软件包,如果有,则检查其依赖冲突关系,如果没有依赖冲突,那么最好,下载安装;如果有,则会给出提示,询问是否要同时安装依赖,或删除冲突的包,你可以自己作出判断:        删除的命令是,yum remove ~,同安装一样,yum也会查询数据库,给出解决依赖关系的提示. 其中~代表软件名 1.用YUM安装软件包命令:yuminstall ~ 2.用Y