六、软件包管理

1 RPM

1 RPM 概述

RPM(RedHat Package Manager),RedHat软件包管理工具,类似windows里面的setup.exe 是Linux这系列操作系统里面的打包安装工具,它虽然是RedHat的标志,但理念是通用的。

RPM包的名称格式

Apache-1.3.23-11.i386.rpm

  • “apache” 软件名称
  • “1.3.23-11”软件的版本号,主版本和此版本
  • “i386”是软件所运行的硬件平台,Intel 32位处理器的统称
  • “rpm”文件扩展名,代表RPM包
2 RPM 查询命令(rpm -qa)
1)基本语法

rpm -qa (功能描述:查询所安装的所有 rpm 软件包)

2)经验技巧

由于软件包比较多,一般都会采取过滤。rpm -qa | grep rpm软件包

3)案例实操

(1)查询firefox软件安装情况

[root@hadoop100 ~]# rpm -qa | grep firefox #查询firefox (火狐)
firefox-68.10.0-1.el7.centos.x86_64
[root@hadoop100 ~]# rpm -qi firefox  #查询详细信息
Name        : firefox
Version     : 68.10.0
Release     : 1.el7.centos
Architecture: x86_64
Install Date: 2022年09月05日 星期一 01时15分07秒
Group       : Unspecified
Size        : 241030932
License     : MPLv1.1 or GPLv2+ or LGPLv2+
Signature   : RSA/SHA256, 2020年07月09日 星期四 00时21分14秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : firefox-68.10.0-1.el7.centos.src.rpm
Build Date  : 2020年07月08日 星期三 02时51分10秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://www.mozilla.org/firefox/
Summary     : Mozilla Firefox Web browser
Description :
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
[root@hadoop100 ~]# 

3 RPM 卸载命令(rpm -e)
1)基本语法

(1)rpm -e RPM软件包
(2) rpm -e --nodeps 软件包

2)选项说明

在这里插入图片描述
在这里插入图片描述

3)案例实操

(1)卸载firefox软件

[root@hadoop101 Packages]# rpm -e firefox
4 RPM 安装命令(rpm -ivh)
1)基本语法

rpm -ivh RPM 包全名

2)选项说明

在这里插入图片描述

3)案例实操

(1)安装firefox软件

[root@hadoop101 Packages]# pwd 
/run/media/root/CentOS 7 x86_64/Packages 
[root@hadoop101 Packages]# rpm -ivh firefox-45.0.1-1.el6.centos.x86_64.rpm 
warning: firefox-45.0.1-1.el6.centos.x86_64.rpm: Header V3 RSA/SHA1 
Signature, key ID c105b9de: NOKEY 
Preparing... ########################################### [100%] 
1:firefox ########################################### [100%]
[root@hadoop100 Packages]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   30G  0 disk 
├─sda1   8:1    0    1G  0 part /boot
├─sda2   8:2    0    4G  0 part [SWAP]
└─sda3   8:3    0   25G  0 part /
sdb      8:16   0   20G  0 disk 
└─sdb1   8:17   0   20G  0 part 
sr0     11:0    1  4.4G  0 rom  /run/media/root/CentOS 7 x86_64
[root@hadoop100 Packages]# cd /run/media/root/CentOS\ 7\ x86_64/
[root@hadoop100 CentOS 7 x86_64]# cd Packages/
[root@hadoop100 Packages]# ls
[root@hadoop100 Packages]# ls |grep firefox
firefox-68.10.0-1.el7.centos.x86_64.rpm
[root@hadoop100 Packages]# rpm -ivh firefox-68.10.0-1.el7.centos.x86_64.rpm 
准备中...                          ################################# [100%]
正在升级/安装...
   1:firefox-68.10.0-1.el7.centos     ################################# [100%]
[root@hadoop100 Packages]# rpm -qi firefox
Name        : firefox
Version     : 68.10.0
Release     : 1.el7.centos
Architecture: x86_64
Install Date: 2022年09月10日 星期六 00时44分16秒
Group       : Unspecified
Size        : 241030932
License     : MPLv1.1 or GPLv2+ or LGPLv2+
Signature   : RSA/SHA256, 2020年07月09日 星期四 00时21分14秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : firefox-68.10.0-1.el7.centos.src.rpm
Build Date  : 2020年07月08日 星期三 02时51分10秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://www.mozilla.org/firefox/
Summary     : Mozilla Firefox Web browser
Description :
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
[root@hadoop100 Packages]# 

2 YUM 仓库配置

1 YUM 概述

YUM(全称为 Yellow dog Updater, Modified)是一个在 Fedora 和 RedHat 以及 CentOS 中的 Shell 前端软件包管理器。基于 RPM 包管理,能够从指定的服务器自动下载 RPM 包 并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软件包,无须繁琐地一次 次下载、安装,

在这里插入图片描述

2 YUM 的常用命令
1)基本语法

yum [选项] [参数]

2)选项说明

在这里插入图片描述

3)参数说明

在这里插入图片描述

4)案例实操实操

(1)采用 yum 方式安装 firefox

[root@hadoop100 Packages]# yum list
[root@hadoop100 Packages]# yum list | grep firefox
firefox.x86_64                            68.10.0-1.el7.centos         @anaconda
firefox.i686                              91.13.0-1.el7.centos         updates  
firefox.x86_64                            91.13.0-1.el7.centos         updates  
[root@hadoop100 Packages]# rpm -qi firefox
Name        : firefox
Version     : 68.10.0
Release     : 1.el7.centos
Architecture: x86_64
Install Date: 2022年09月10日 星期六 00时44分16秒
Group       : Unspecified
Size        : 241030932
License     : MPLv1.1 or GPLv2+ or LGPLv2+
Signature   : RSA/SHA256, 2020年07月09日 星期四 00时21分14秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : firefox-68.10.0-1.el7.centos.src.rpm
Build Date  : 2020年07月08日 星期三 02时51分10秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : https://www.mozilla.org/firefox/
Summary     : Mozilla Firefox Web browser
Description :
Mozilla Firefox is an open-source web browser, designed for standards
compliance, performance and portability.
[root@hadoop100 Packages]#
[root@hadoop100 Packages]# yum remove firefox #卸载firefox 
[root@hadoop100 Packages]# yum list | grep firefox
firefox.i686                              91.13.0-1.el7.centos         updates  
firefox.x86_64                            91.13.0-1.el7.centos         updates  
[root@hadoop100 Packages]#
[root@hadoop100 Packages]# rpm -q firefox
未安装软件包 firefox 
[root@hadoop100 Packages]# 
[root@hadoop100 Packages]# yum -y install firefox  #安装 firefox  
[root@hadoop100 Packages]# yum list | grep firefox
firefox.x86_64                            91.13.0-1.el7.centos         @updates  # 后面加@ 符号说明是已经安装的版本
firefox.i686                              91.13.0-1.el7.centos         updates  
[root@hadoop100 Packages]# 
[root@hadoop100 Packages]# rpm -q firefox
firefox-91.13.0-1.el7.centos.x86_64
[root@hadoop100 Packages]# 

3 修改网络 YUM 源

默认的系统 YUM 源,需要连接国外 apache 网站,网速比较慢,可以修改关联的网络 YUM 源为国内镜像的网站,比如网易 163,aliyun 等

1)安装 wget, wget 用来从指定的 URL 下载文件
[root@hadoop101 ~] yum install wget
2)在/etc/yum.repos.d/目录下,备份默认的 repos 文件,
[root@hadoop101 yum.repos.d] pwd 
/etc/yum.repos.d 
[root@hadoop101 yum.repos.d] cp CentOS-Base.repo CentOS-Base 
.repo.backup
3)下载网易 163 或者是 aliyun 的 repos 文件,任选其一,
[root@hadoop101 yum.repos.d] wget
http://mirrors.aliyun.com/repo/Centos-7.repo //阿里云 
[root@hadoop101 yum.repos.d] wget 
http://mirrors.163.com/.help/CentOS7-Base-163.repo //网易 163

在这里插入图片描述

4)使用下载好的 repos 文件替换默认的 repos 文件

例如:用 CentOS7-Base-163.repo 替换 CentOS-Base.repo

[root@hadoop101 yum.repos.d]# mv CentOS7-Base-163.repo CentOS-Base.repo
5)清理旧缓存数据,缓存新数据
[root@hadoop101 yum.repos.d]#yum clean all 
[root@hadoop101 yum.repos.d]#yum makecache

yum makecache 就是把服务器的包信息下载到本地电脑缓存起来

6)测试
[root@hadoop101 yum.repos.d]# yum list | grep firefox 
[root@hadoop101 ~]#yum -y install firefox
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值