linux-管理rpm包

本文详细介绍了Linux系统中RPM包管理的基本概念,包括RPM包的名称构成。接着深入讲解了YUM管理RPM包,包括yum源的类型、配置、常用命令以及签名检查机制。此外,还阐述了如何将安装光盘和普通目录配置成本地yum源的方法。
摘要由CSDN通过智能技术生成

一、概念

1、RPM:RPM是RedHat Package Manager(RedHat软件包管理工具)的缩写。
2、RPM包的名称构成:

例如:ypserv-2.31-12.el7.x86_64.rpm,yelp-xsl-3.28.0-1.el7.noarch.rpm

软件包名 版本号 发布版本 系统平台
ypserv 2.31 12.el7 x86_64
yelp-xsl 3.28.0 1.el7 noarch

二、yum管理rpm包

1、yum源:
(1)、默认源:BASE/Extras/Updates默认都是国外源,可以替换为国内镜像源,比如阿里和网易的镜像源(https://developer.aliyun.com/mirror ,http://mirrors.163.com)
(2)、EPEL 源:EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS等。默认是国外源;可以替换为国内阿里云镜像。
(3)、第三方软件源:比如mysql,zabbix等等都有自己的官方源
(4)、yum源配置文件

存放位置:/etc/yum.repos.d/*.repo
源配置文件中的主要参数:
[base] ##标签名称
name=CentOS-$releasever - Base ##名称
baseurl=http://mirror.centos.org/centos/ r e l e a s e v e r / o s / releasever/os/ releasever/os/basearch/ ##r指向yum存储库的“repodata”目录所在目录的URL,可以是http://, ftp:// or file://
gpgcheck=1 ## 是否签名检查 1: 检查 0:不检查
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ## 签名检查密钥文件

2、yum命令:

使用yum安装软件包时可以自动寻找依赖包并安装。

(1)、查看可用仓库:
##清空缓存文件
[root@centos7u7 yum.repos.d]# yum clean all
已加载插件:fastestmirror
正在清理软件源: base extras updates
Cleaning up list of fastest mirrors

##重建缓存
[root@centos7u7 yum.repos.d]# yum makecache
已加载插件:fastestmirror
Determining fastest mirrors
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
base                                                   | 3.6 kB  00:00:00     
extras                                                 | 2.9 kB  00:00:00     
updates                                                | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                         | 165 kB  00:00:00     
(2/10): extras/7/x86_64/filelists_db                   | 207 kB  00:00:01     
(3/10): extras/7/x86_64/primary_db                     | 153 kB  00:00:01     
(4/10): extras/7/x86_64/other_db                       | 100 kB  00:00:01     
(5/10): base/7/x86_64/other_db                         | 2.6 MB  00:00:13     
(6/10): updates/7/x86_64/filelists_db                  | 2.1 MB  00:00:13     
(7/10): updates/7/x86_64/other_db                      | 243 kB  00:00:01     
(8/10): updates/7/x86_64/primary_db                    | 2.8 MB  00:00:15     
(9/10): base/7/x86_64/filelists_db                     | 7.3 MB  00:00:21     
(10/10): base/7/x86_64/primary_db                      | 6.0 MB  00:00:21     
元数据缓存已建立

##查询可用仓库
[root@centos7u7 yum.repos.d]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
源标识                        源名称                        状态
base/7/x86_64                 CentOS-7 - Base               10,097
extras/7/x86_64               CentOS-7 - Extras                305
updates/7/x86_64              CentOS-7 - Updates               711
repolist: 11,113

(2)、查询命令:

查询命令是从本地rpm数据库和yum源中查询

命令 功能
yum list bash-completion 查找某个包,全匹配
yum list bash-com* 查找某个包,模糊匹配,只在名称查找匹配
yum list|grep ^bash-com 查找某个包,模糊匹配,只在名称查找匹配
yum search chinese 在名称和描述中查找关键字,上面的命令只在名称中查找
yum list installed 列出已安装的包
yum info bash-completion.noarch 显示包的详细信息
yum provides /etc/yum.conf 查找文件由哪个包提供
yum provides watch 查找命令由哪个包提供
##查询某一rpm包,可以全匹配或模糊匹配,结果中的@代表已安装
[root@centos7u7 yum.repos.d]# yum list bash-completion
[root@centos7u7 yum.repos.d]# yum list bash-com*
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
bash-completion.noarch             1:2.1-6.el7            @base
[root@centos7u7 yum.repos.d]# yum list|grep ^bash-com
bash-completion.noarch                      1:2.1-6.el7                @base

##列出安装软件包
[root@centos7u7 yum.repos.d]# yum list installed

##列出软件包详细信息
[root@centos7u7 yum.repos.d]# yum info bash-completion.noarch 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
已安装的软件包
名称    :bash-completion
架构    :noarch
时期       :1
版本    :2.1
发布    :6.el7
大小    :259 k
源    :installed
来自源:base
简介    : Programmable completion for Bash
网址    :http://bash-completion.alioth.debian.org/
协议    : GPLv2+
描述    : bash-completion is a collection of shell functions that take advantage
         : of the programmable completion feature of bash.


[root@centos7u7 yum.repos.d]# yum search chinese
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
======================================================= N/S matched: chinese ========================================================
ghostscript-chinese.noarch : Common files for ghostscript-chinese
ghostscript-chinese-zh_CN.noarch : Ghostscript Simplified Chinese fonts configuration files
ghostscript-chinese-zh_TW.noarch : Ghostscript Traditional Chinese fonts configuration files
google-noto-sans-simplified-chinese-fonts.noarch : Sans Simplified Chinese font
google-noto-sans-traditional-chinese-fonts.noarch : Sans Traditional Chinese font
ibus-table-chinese.noarch : Chinese input tables for IBus
kde-l10n-Chinese.noarch : Chinese (Simplified Chinese) language support for KDE
kde-l10n-Chinese-Traditional.noarch : Chinese (Traditional) language support for KDE
autocorr-zh.noarch : Chinese auto-correction rules
cjkuni-ukai-fonts.noarch : Chinese Unicode TrueType font in Kai face

##查找文件由哪个包提供
[root@centos7u7 yum.repos.d]# yum provides /etc/yum.conf
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
yum-3.4.3-163.el7.centos.noarch : RPM package installer/updater/manager
源    :base
匹配来源:
文件名    :/etc/yum.conf

yum-3.4.3-163.el7.centos.noarch : RPM package installer/updater/manager
源    :@anaconda
匹配来源:
文件名    :/etc/yum.conf

##查找命令由哪个包提供
[root@centos7u7 yum.repos.d]# yum provides watch
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.tuna.tsinghua.edu.cn
procps-ng-3.3.10-26.el7.i686 : System and process monitoring utilities
源    :base
匹配来源:
文件名    :/usr/bin/watch



procps-ng-3.3.10-26.el7.x86_64 : System and process monitoring utilities
源    :base
匹配来源:
文件名    :/usr/bin/watch



procps-ng-3.3.10-26.el7_7.1.i686 : System and process monitoring utilities
源    :updates
匹配来源:
文件名    :/usr/bin/watch

(3)、安装命令
命令 功能
yum -y install vsftpd *vnc 安装vsftpd,*vnc软件包
yum -y reinstall httpd 重装httpd软件包
yum -y updatevsftpd 更新vsftpd软件包
yum -y update 更新所有已安装软件包
yum -y install /media/Packages/yp-tools-2.9-12.el6.x86_64.rpm 从本地安装软件包
yum install https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.28-1.el7.x86_64.rpm 从网络安装软件包
[root@centos6 ~]# yum -y reinstall vsftpd
已加载插件:fastestmirror, refresh-packagekit, security
设置覆盖安装进程
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * extras: mirror.bit.edu.cn
 * updates: mirror.bit.edu.cn
解决依赖关系
--> 执行事务检查
---> Package vsftpd.x86_64 0:2.2.2-24.el6 will be reinstalled
--
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值