文章目录
19. 软件管理 19.1 linux软件介绍 19.2 RPM包概述 19.3 RPM软件包安装 19.4 RPM软件包依赖问题 19.5 DPKG软件包 19.6 linux 软件包前端工具 19.7 windows 前端工具winget 19.8 linux 前端工具yum概述 19.9 设置yum远程仓库 19.10 yum 软件包管理 19.11 epel软件仓库 19.12 yum本地ISO仓库管理 19.13 软件包组管理
19. 软件管理
19.1 linux软件介绍
一个软件执行需要依赖操作系统中的各种函数库和中间件
windows: xx.exe xx.msi | windows系统软件无法在Linux中执行
$# 1 .
linux: 软件包类型:
rpm软件包: 已经编译好的二进制软件包,可以在系统中直接进行安装
安装速度快
不灵活,针对某个平台,通常只支持特定的平
台( centos) ,极大的软件依赖
无法修改源代码( 高手可以做反编译)
源代码包: 没有经过二进制编译的软件,无法在系统直接进行安装使用,需要进行编译之后可以进行安装使用
安装过程及其负责, 容易出错,不好排错
灵活,可以修改源代码
$# 2 . linux软件包获取:
( 1 ) 官方网站下载 ( 把部分都是源码包)
( 2 ) 安装光盘package路径 ( 包含大量rpm包)
( 3 ) 软件仓库中 ( 包含大量rpm包)
$# 3 . 获取安装光盘package路径中的软件包
( 1 ) 确保主机连接到ISO光盘
( 2 ) 光盘挂载
[ root@HCIE ~]
[ root@HCIE ~]
[ root@HCIE ~]
[ root@HCIE mnt]
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[ root@HCIE mnt]
[ root@HCIE Packages]
3895
[ root@HCIE Packages]
19.2 RPM包概述
$# 1 . RPM ( Redhat Package Manager)
http://rpm.org/
RPM Package Manager
httpd-2.4.6-67.el7.centos.x86_64.rpm 软件包全名
httpd 软件包名称
2.4 .6 软件包版本
67 软件包发行次数
el7 使用于RHEL 7 系统系列
centos 精确适用于centos平台
x86 软件包适用于x86平台
64 64 位软件版本
noarch 该软件包适用于el7平台的不同系统,不受到限制
yum-utils-1.1.31-42.el7.noarch.rpm
19.3 RPM软件包安装
$# 1 . rpm 工具介绍
1.1 软件包类型
1.2 软件包安装工具
采用rpm软件工具安装rpm类型的软件包
rpm软件工具通常在系统出厂自带
[ root@HCIE Packages]
RPM version 4.11 .3
[ root@HCIE Packages]
如果系统中出厂没有自带rpm安装工具,需要下载rpm安装工具,rpm安装工具需要采用源码包安装
http://rpm.org/download.html
rpm-4.18.0.tar.bz2
$# 2 . rpm 工具使用
rpm 相关常用重要参数
-i : 安装
-v : 显示安装详细信息
-e : 卸载
-h : 显示安装进度
-q : 查看软件包是否安装
-qa : 查看该系统中安装的所有RPM软件包
-qi : 查看安装的软件信息
-ql : 查看软件的安装位置
-qf : 查看软件包的安装来源
--force : 强制安装
[ root@HCIE Packages]
1281
[ root@HCIE Packages]
[ root@HCIE Packages]
/mnt/Packages
[ root@HCIE Packages]
warning: vsftpd-3.0.2-22.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :vsftpd-3.0.2-22.el7
[ root@HCIE Packages]
[ root@HCIE Packages]
vsftpd-3.0.2-22.el7.x86_64
[ root@HCIE Packages]
vsftpd-3.0.2-22.el7.x86_64
[ root@HCIE Packages]
[ root@HCIE Packages]
Name : vsftpd
Version : 3.0 .2
Release : 22 .el7
Architecture: x86_64
Install Date: Wed 08 Feb 2023 01:22:20 AM CST
Group : System Environment/Daemons
Size : 356236
License : GPLv2 with exceptions
Signature : RSA/SHA256, Fri 11 Aug 2017 04:17:26 AM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : vsftpd-3.0.2-22.el7.src.rpm
Build Date : Thu 03 Aug 2017 02:10:20 PM CST
Build Host : c1bm.rdu2.centos.org
Relocations : ( not relocatable)
Packager : CentOS BuildSystem < http://bugs.centos.org>
Vendor : CentOS
URL : https://security.appspot.com/vsftpd.html
Summary : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
[ root@HCIE Packages]
[ root@HCIE Packages]
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/vsftpd
/var/ftp/pub
[ root@HCIE Packages]
[ root@HCIE Packages]
Preparing.. .
Cleaning up / removing.. .
1 :vsftpd-3.0.2-22.el7
[ root@HCIE Packages]
[ root@HCIE Packages]
package vsftpd is not installed
[ root@HCIE Packages]
19.4 RPM软件包依赖问题
$# 1 . 软件包依赖
在安装当前软件时,必须提前安装其他软件 ( 安装A之前,必须安装B)
$# 2 . 树形依赖/模块依赖/环形依赖
[ root@HCIE Packages]
package httpd is not installed
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: httpd-2.4.6-67.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
/etc/mime.types is needed by httpd-2.4.6-67.el7.centos.x86_64
httpd-tools = 2.4 .6-67.el7.centos is needed by httpd-2.4.6-67.el7.centos.x86_64
libapr-1.so.0( ) ( 64bit) is needed by httpd-2.4.6-67.el7.centos.x86_64
libaprutil-1.so.0( ) ( 64bit) is needed by httpd-2.4.6-67.el7.centos.x86_64
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: httpd-tools-2.4.6-67.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
libapr-1.so.0( ) ( 64bit) is needed by httpd-tools-2.4.6-67.el7.centos.x86_64
libaprutil-1.so.0( ) ( 64bit) is needed by httpd-tools-2.4.6-67.el7.centos.x86_64
[ root@HCIE Packages]
[ root@HCIE Packages]
package libapr is not installed
[ root@HCIE Packages]
*如果在软件安装依赖中出现 so.0( ) 表示模块依赖,需要查找模块对应的RPM软件包
http://www.rpmfind.net/
[ root@HCIE Packages]
apr-1.4.8-3.el7.x86_64.rpm
apr-devel-1.4.8-3.el7.x86_64.rpm
apr-util-1.5.2-6.el7.x86_64.rpm
apr-util-devel-1.5.2-6.el7.x86_64.rpm
haproxy-1.5.18-6.el7.x86_64.rpm
[ root@HCIE Packages]
warning: apr-1.4.8-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :apr-1.4.8-3.el7
[ root@HCIE Packages]
warning: apr-util-1.5.2-6.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :apr-util-1.5.2-6.el7
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: httpd-tools-2.4.6-67.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :httpd-tools-2.4.6-67.el7.centos
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: httpd-2.4.6-67.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
/etc/mime.types is needed by httpd-2.4.6-67.el7.centos.x86_64
[ root@HCIE Packages]
[ root@HCIE Packages]
mailcap-2.1.41-2.el7.noarch.rpm
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: mailcap-2.1.41-2.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :mailcap-2.1.41-2.el7
[ root@HCIE Packages]
[ root@HCIE Packages]
warning: httpd-2.4.6-67.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing.. .
Updating / installing.. .
1 :httpd-2.4.6-67.el7.centos
[ root@HCIE Packages]
[ root@HCIE Packages]
httpd-2.4.6-67.el7.centos.x86_64
httpd-tools-2.4.6-67.el7.centos.x86_64
[ root@HCIE Packages]
19.5 DPKG软件包
$# 1 .
fedora / RHEL / centos / Rocky / Euleros -> 软件包格式rpm
SUSE opensuse -> 软件包格式rpm
Debian / Ubuntu / kail -> 软件包格式deb / 安装工具 Debian Package ( DPKG)
dpkg -l
dpkg -i xxxx.deb
dpkg -r xxxx
19.6 linux 软件包前端工具
$# 1 .
rpm方式/dpkg方式 安装软件包时,需要自己处理依赖关系
可以通过linux软件包前端工具自动处理依赖关系
fedora / RHEL / centos / Rocky / Euleros -> 软件包格式rpm/安装工具rpm /前端工具yum/dnf
SUSE opensuse -> 软件包格式rpm /前端工具zypper
Debian / Ubuntu / kail -> 软件包格式deb / 安装工具 Debian Package ( DPKG) /前端工具apt( apt-get)
windows / 前端工具winget
MACOS / 前端工具brew
19.7 windows 前端工具winget
$# 1 . 实际上是去远端仓库
( 部分) windows 11 系统自带winget
windows10/11系统可以
winget工具 - 远程仓库在国外
C:\ Users\ zy> winget -v
v1.4.10173
C:\ Users\ zy>
winget search xxxx
winget install xxxx
winget uninstall xxxx
https://learn.microsoft.com/zh-cn/windows/package-manager/winget/
19.8 linux 前端工具yum概述
$# 1 .
yum ( Yellow dog Updater, Modified)
作用: 解决rpm软件包安装依赖性
基础原理: 从远端仓库中下载软件并且安装
yum仓库:
yum远程仓库: 远程仓库通常由官方搭建
yum本地仓库: 本地仓库通常由自己搭建
yum配置文件
记录yum仓库信息
/etc/yum.repos.d/
文件格式: xxx.repo
在使用yum安装软件之前,必须要创建yum仓库配置文件
[ root@HCIE Packages]
[ root@HCIE yum.repos.d]
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[ root@HCIE yum.repos.d]
$# 2 . yum仓库
1 . Base( 默认使用)
CentOS-Base.repo
2 . Media( 默认情况下不用)
CentOS-Media.repo
3 . other( 提供额外扩展功能,特定情况下会被使用)
CentOS-Debuginfo.repo CentOS-Vault.repo CentOS-CR.repo
CentOS-fasttrack.repo CentOS-Sources.repo
$# 3 . yum仓库配置文件信息
[ 仓库名称]
baseurl = 仓库位置-链接
mirrorlist = 镜像列表-链接( 高可用)
enabled = 0 该仓库不可用 1 该仓库可用(default)
gpgcheck = 0 不对软件包进行校验 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ///软件包校验密钥文件路径
[ root@HCIE yum.repos.d]
[ base] - 基础软件包
[ updates] - 发布软件更新仓库
[ extras] - 额外附加软件包仓库
[ centosplus] - centos功能扩展附加软件包仓库
mirrorlist 链接中的存储软件包和baseurl是相同的,
1 . 提供mirrorlist 增加baseurl的可用性
2 . 就近下载
mirrorlist = http://mirrorlist.centos.org/release= $releasever & arch = $basearch & repo = os& infra = $infra
baseurl = http://mirror.centos.org/centos/$releasever /os/$basearch /
[ root@HCIE yum.repos.d]
Server: 114.114 .114.114
Address: 114.114 .114.114
Non-authoritative answer:
Name: mirrorlist.centos.org
Address: 85.236 .43.108
Name: mirrorlist.centos.org
Address: 67.219 .148.138
Name: mirrorlist.centos.org
Address: 18.225 .36.18
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
Server: 114.114 .114.114
Address: 114.114 .114.114
Non-authoritative answer:
Name: mirror.centos.org
Address: 43.205 .141.181
[ root@HCIE yum.repos.d]
默认情况下
mirrorlist
19.9 设置yum远程仓库
$# 1 . 国内第三方镜像源
目前 centos官方源/官方镜像软件源都不在国内,国内大陆服务器访问速度相对较慢
$# 2 .
1 . 备份原有的默认仓库配置文件
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
bak
[ root@HCIE yum.repos.d]
2 . 创建/下载新的仓库配置文件
https://developer.aliyun.com/mirror/
[ root@HCIE yum.repos.d]
--2023-02-08 04:48:29-- https://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com ( mirrors.aliyun.com) .. . 120.226 .194.118, 120.226 .194.119, 120.226 .194.112, .. .
Connecting to mirrors.aliyun.com ( mirrors.aliyun.com) | 120.226 .194.118| :443.. . connected.
HTTP request sent, awaiting response.. . 200 OK
Length: 2523 ( 2 .5K) [ application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100 %[ == == == == == == == == == == == == == == == == == == == == == == == == == == == == > ] 2,523 --.-K/s in 0s
2023 -02-08 04:48:35 ( 591 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [ 2523 /2523]
[ root@HCIE yum.repos.d]
bak CentOS-Base.repo
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
base extras timedhosts timedhosts.txt updates
[ root@HCIE yum.repos.d]
3 . 清楚原有的本地配置文件
[ root@HCIE yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[ root@HCIE yum.repos.d]
base extras timedhosts updates
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
4 . 重新建立yum缓存
[ root@HCIE yum.repos.d]
5 . 查看系统的所有yum源
[ root@HCIE yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com enabled: 10,072
centosplus/7/x86_64 CentOS-7 - Plus - mirrors.aliyun.com disabled
contrib/7/x86_64 CentOS-7 - Contrib - mirrors.aliyun.com disabled
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com enabled: 515
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com enabled: 4,691
repolist: 15,278
[ root@HCIE yum.repos.d]
6 . 查看系统中可用的yum源
[ root@HCIE yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,072
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 515
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 4,691
repolist: 15,278
[ root@HCIE yum.repos.d]
19.10 yum 软件包管理
$# 1 . 常见参数
1 . 安装卸载
install 安装
remove 卸载
-y 查询时使用,自动填写yes
histor 查看历史
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
2 . 历史查看
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
3 . 更新/升级
update 更新
upgrade 升级 ( 会删除旧版本)
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
yum update && obsoletes = 0 ( 不会删除旧版本)
yum update --absoletes = yum upgrade( 会删除旧版本)
--absoletes
[ root@HCIE yum.repos.d]
obsoletes = 1 ( 会删除旧版本)
[ root@HCIE yum.repos.d]
4 . 查看当前软件仓库中的可用的软件包
[ root@HCIE yum.repos.d]
vsftpd.x86_64 3.0 .2-29.el7_9 updates
vsftpd-sysvinit.x86_64 3.0 .2-29.el7_9 updates
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
19.11 epel软件仓库
$# Extra Packages for Enterprise Linux - EPEL
1 . fedora社区打造高质量软件仓库( 有部分EHEL收费的软件包)
2 . 免费
[ root@HCIE yum.repos.d]
epel-release.noarch 7 -11 extras
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
bak CentOS-Base.repo epel.repo epel-testing.repo
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
[ root@HCIE yum.repos.d]
19.12 yum本地ISO仓库管理
$# 1 . 本地无网络场景下,挂载ISO镜像
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ local_mnt]
baseurl = file:///mnt
enabled = 1
gpgcheck = 0
[ root@localhost yum.repos.d]
file://
file:///mnt
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Repository 'local_mnt' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
repo id repo name status
local_mnt local_mnt enabled: 3,894
repolist: 3,894
[ root@localhost yum.repos.d]
19.13 软件包组管理
$# 1 . minimal安装,想装GUI
minimal: 200 多个包,连vim都没有
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ local_mnt]
baseurl = file:///mnt
enabled = 1
gpgcheck = 0
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
299
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
Loaded plugins: fastestmirror, langpacks
Repository 'local_mnt' is missing name in configuration, using id
There is no installed groups file.
Maybe run: yum groups mark convert ( see man yum)
Loading mirror speeds from cached hostfile
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Compatibility Libraries
Console Internet Tools
Development Tools
Graphical Administration Tools
Legacy UNIX Compatibility
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
Done
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
1369
[ root@localhost yum.repos.d]
[ root@localhost yum.repos.d]
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
[ root@localhost yum.repos.d]