Linux7.2 yum工具

可以发现安装某些包,需要另一些包的支持,遇到多重依赖关系包,安装比较麻烦。

[root@chy002 Packages]# rpm -ivh texlive-2012-32.20130427_r30134.el7.x86_64.rpm
错误:依赖检测失败:
        texlive-scheme-basic 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 需要
        texlive-collection-latexrecommended 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 需要
        tex-kpathsea 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 需要
        tex-tetex 被 texlive-2:2012-32.20130427_r30134.el7.x86_64 需要

yum工具可以自动解决依赖关系

[root@chy002 Packages]# yum install texlive
... ...
安装  1 软件包 (+246 依赖软件包)

总下载量:123 M
安装大小:237 M
Is this ok [y/d/N]:

... ...

yum工具用法

#yum   list      列出可用rpm包

[root@chy002 Packages]#yum list
... ...
zziplib-devel.x86_64                                   0.13.62-5.el7                        base
zziplib-utils.x86_64                                   0.13.62-5.el7                        base

#yum list中仓库名的base是来自仓库配置文件中的 [base]
[root@chy002 Packages]# ls /etc/yum
yum/         yum.conf     yum.log      yum.repos.d/
[root@chy002 Packages]# ls /etc/yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@chy002 Packages]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$rele
... ...


#搜索包    yum search  vim   不够精准,说明中带的vim也过滤出
[root@chy002 Packages]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
========================================= N/S matched: vim ==========================================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor

  名称和简介匹配 only,使用“search all”试试。

#较精准搜索
[root@chy002 Packages]# yum list |grep 'vim'
vim-common.x86_64                          2:7.4.160-2.el7             @base
vim-enhanced.x86_64                        2:7.4.160-2.el7             @base
vim-filesystem.x86_64                      2:7.4.160-2.el7             @base
vim-minimal.x86_64                         2:7.4.160-1.el7             @anaconda
protobuf-vim.x86_64                        2.5.0-8.el7                 base
vim-X11.x86_64                             2:7.4.160-2.el7             base
vim-minimal.x86_64                         2:7.4.160-2.el7             base

#安装包  yum install -y  包名

#列出可用安装组、套件
[root@chy002 Packages]# yum grouplist
... ...
Available environment groups:
   最小安装
... ...
   开发及生成工作站
可用组:
   传统 UNIX 兼容性
   ... ...
   系统管理工具
完成

#安装组、套件  yum groupinstall -y 

#卸载  yum  remove -y

#更新  yum   update  -y

#通过命令搜索包名     yum  provides   "/*/命令"
[root@chy002 Packages]# yum provides "/*/pstree"
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system
源    :base
匹配来源:
文件名    :/usr/bin/pstree



psmisc-22.20-15.el7.x86_64 : Utilities for managing processes on your system
源    :@base
匹配来源:
文件名    :/usr/bin/pstree

yum搭建本地仓库

  Linux系统不能联网就不能使用联网的yum源了,可以利用Linux系统光盘制作一个yum源。

#挂载光盘
mount /dev/cdrom  /mnt

#备份,删除/etc/yum.repos.d 目录所有的repo文件
cp -r /etc/yum.repos.d /etc/yum.repos.d.bak
rm -rf /etc/yum.repos.d/*

#创建新的dvd.repo文件
[root@chy002 yum.repos.d]# cat dvd.repo
[dvd]
name=install dvd
baseurl=file:///mnt
enabled=1
gpgcheck=0

#刷新repos生成缓存
yum makecache


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

zenity.x86_64                                   3.8.0-4.el7                          dvd
zlib-devel.x86_64                               1.2.7-13.el7                         dvd
zsh.x86_64                                      5.0.2-7.el7                          dvd
zziplib.x86_64                                  0.13.62-5.el7                        dvd

yum更换国内源

  备份仓库源配置文件。通过wget + 链接  或者  curl  -O  + 链接    下载yum源配置文件到该文件夹下,然后yum clean all清空缓存。

首先备份/etc/yum.repos.d/CentOS-Base.repo
    mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
http://mirrors.163.com/.help/CentOS5-Base-163.repo
http://mirrors.163.com/.help/CentOS6-Base-163.repo

运行以下命令生成缓存
    yum clean all
    yum makecache

yum下载rpm包

安装扩展源 

  有时候系统源没有该rpm包,需要安装扩展源epel

[root@chy002 etc]# cp -r yum.repo.d.bak/* yum.repos.d/
[root@chy002 etc]# ls yum.repos.d/
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Sources.repo  CentOS-Vault.repo
[root@chy002 etc]# yum install -y epel-release
已加载插件:fastestmirror
base                                                                   | 3.6 kB  00:00:00
extras                                                                 | 3.4 kB  00:00:00
updates                                                                | 3.4 kB  00:00:00
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.zju.edu.cn
 * updates: centos.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-9 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================
 Package                    架构                 版本              源                    大小
==============================================================================================
正在安装:
 epel-release               noarch               7-9               extras                14 k

事务概要
==============================================================================================
安装  1 软件包

总下载量:14 k
安装大小:24 k
Downloading packages:
epel-release-7-9.noarch.rpm                                            |  14 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : epel-release-7-9.noarch                                                   1/1
  验证中      : epel-release-7-9.noarch                                                   1/1

已安装:
  epel-release.noarch 0:7-9

完毕!
[root@chy002 etc]# cd yum.repos.d
[root@chy002 yum.repos.d]# ls
CentOS-Base.repo       CentOS-Sources.repo  epel.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo    epel-testing.repo

yum下载rpm包到本地

#可以下载一个没有安装过的rpm包
yum install -y 包名  --downloadonly  --downloaddir=路径

[root@chy002 tmp]# yum install  zvbi-devel.x86_64  -y --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
... ...
Background downloading packages, then exiting:
警告:/var/cache/yum/x86_64/7/epel/packages/zvbi-devel-0.2.35-1.el7.x86_64.rpm.2734.tmp: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY

... ...

#可以发现,该rpm包下载的地址 /var/cache/yum/x86_64/7/epel/packages/

#如果下载已安装的rpm包
[root@chy002 tmp]# yum install  vim-enhanced  -y --downloadonly
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirrors.ustc.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: centos.ustc.edu.cn
软件包 2:vim-enhanced-7.4.160-2.el7.x86_64 已安装并且是最新版本
无须任何处理
[root@chy002 tmp]# yum reinstall  vim-enhanced  -y --downloadonly  --downloaddir=/tmp/
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * epel: mirror01.idc.hinet.net
 * extras: mirrors.zju.edu.cn
... ...

Background downloading packages, then exiting:
vim-enhanced-7.4.160-2.el7.x86_64.rpm                                  | 1.0 MB  00:00:03
exiting because "Download Only" specified
[root@chy002 tmp]# ls
123      chyuanliu1                             yum_save_tx.2017-11-14.04-12.cXiZgk.yumtx
123.txt  passwd.txt                             yum_save_tx.2017-11-14.06-12.tVu9wM.yumtx
321.txt  vim-enhanced-7.4.160-2.el7.x86_64.rpm  yum_save_tx.2017-11-14.06-26.O985nb.yumtx

  

 

posted @ 2017-11-13 22:31  chyuanliu  阅读(599)  评论(0编辑  收藏  举报