案头见蠹鱼,犹胜凡俦侣。这篇文章主要讲述yum管理工具相关的知识,希望能为你提供帮助。
yum管理工具【yum管理工具】
[TOC]
yum安装
yum安装方式
- 本地安装:
yum localinstall -y 包名 (前提该包已经下载在服务器上了)
- yum源安装:
yum install -y 命令
- 网站安装:
yum install -y http://test.driverzeng.com/nginx_package/nginx-1.12.2-
3.el7.x86_64.rpm
自动解决依赖关系的前提条件:在你的所有yum中都要有该软件的依赖包
yum重装
yum reinstall -y 包名
作用:误删了该服务相关的任何一个文件,使用reinstall都可以恢复,但是恢复的是最初始的配置
reinstall的方式,必须跟最开始安装这个包的方式一致
yum更新
# 查看当前系统中,有哪些软件是可以更新的
[root@zxw < sub> ]# yum check-update
# 更新指定的软件包
[root@zxw < /sub> ]# rpm update -y 包名
# 更新所有可更新的软件包
[root@zxw < sub> ]# rpm update -y(此命令危险)
原因:
[root@zxw < /sub> ]# yum check-update|grep kernel
kernel.x86_643.10.0-1160.62.1.el7updates
kernel-tools.x86_643.10.0-1160.62.1.el7updates
kernel-tools-libs.x86_643.10.0-1160.62.1.el7updates
[root@zxw ~]# uname -a
Linux zxw 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
(如果执行了这个命令它会把内核也更新了,如果内核更新了当前的系统版本也就更新了)
yum卸载
[root@zxw < sub> ]# yum erase -y 包名
[root@zxw < /sub> ]# yum remove -y 包名
yum仓库指令
# 查看所有源中可用的yum仓库
[root@zxw < sub> ]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
仓库名(包)仓库描述仓库状态(多少个)
repo idrepo namestatus
base/7/x86_64CentOS-7 - Base - mirrors.aliyun.com10,072
epel/x86_64Extra Packages for Enterprise Linux 7 - x86_6413,751
extras/7/x86_64CentOS-7 - Extras - mirrors.aliyun.com509
nginx-stable/7/x86_64nginx stable repo262
updates/7/x86_64CentOS-7 - Updates - mirrors.aliyun.com3,728
repolist: 28,322
# 查看所有源中,所有的yum仓库
[root@zxw < /sub> ]# yum repolist all
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
仓库名(包)仓库描述仓库状态(多少个)
repo idrepo namestatus
base/7/x86_64CentOS-7 - Base - mirrors.aliyun.comenabled: 10,072
centosplus/7/x86_64CentOS-7 - Plus - mirrors.aliyun.comdisabled
contrib/7/x86_64CentOS-7 - Contrib - mirrors.aliyun.comdisabled
epel/x86_64Extra Packages for Enterprise Linux 7 - x86_64enabled: 13,751
epel-debuginfo/x86_64Extra Packages for Enterprise Linux 7 - x86_64 - disabled
epel-sourceExtra Packages for Enterprise Linux 7 - x86_64 - disabled
extras/7/x86_64CentOS-7 - Extras - mirrors.aliyun.comenabled:509
nginx-mainline/7/x86_64 nginx mainline repodisabled
nginx-stable/7/x86_64nginx stable repoenabled:262
updates/7/x86_64CentOS-7 - Updates - mirrors.aliyun.comenabled:3,728
repolist: 28,322
# 使用 yum-config-manager
# 1.没有命令,要安装命令
[root@zxw < sub> ]# yum install -y yum-config-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
No package yum-config-manager available.
Error: Nothing to do
# 2.查询该命令属于那个包
[root@zxw < /sub> ]# yum provides */yum-config-manager
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
yum-utils-1.1.31-54.el7_8.noarch : Utilities based around the yum package manager
Repo: base
Matched from:
Filename: /usr/bin/yum-config-manager
# 3.安装对应的rpm包
[root@zxw < sub> ]# yum install -y yum-utils
# 修改yum源配置文件,开启或关闭仓库
# 1.开启
[root@zxw < /sub> ]# yum-config-manager --enable nginx-mainline
# 2.关闭
[root@zxw ~]# yum-config-manager --disable nginx-mainline
yum缓存命令
# 清除所有的缓存
yum clean all
# 加载缓存
yum makecache
# 默认情况下,yum是不会下载rpm包的,只会安装
# 除非开启下载的配置
vim /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0(# 把这个0改成1就会下载rpm包了)
# yum下载后rpm包的默认路径
[root@zxw < sub> ]# ll /var/cache/yum/x86_64/7/
total 28
drwxr-xr-x. 4 root root 4096 Apr 24 14:56 base
drwxr-xr-x. 4 root root33 Apr 23 21:33 centosplus
drwxr-xr-x. 4 root root33 Apr 23 21:33 contrib
drwxr-xr-x. 4 root root 4096 Apr 24 14:56 epel
drwxr-xr-x. 4 root root33 Apr 23 21:33 epel-debuginfo
drwxr-xr-x. 4 root root33 Apr 23 21:33 epel-source
drwxr-xr-x. 4 root root 4096 Apr 24 14:56 extras
drwxr-xr-x. 4 root root33 Apr 23 21:33 nginx-mainline
drwxr-xr-x. 4 root root 4096 Apr 24 14:56 nginx-stable
-rw-r--r--. 1 root root202 Apr 24 14:57 timedhosts
-rw-r--r--. 1 root root107 Apr 24 14:56 timedhosts.txt
drwxr-xr-x. 4 root root 4096 Apr 24 14:57 updates
# 下载tree,不安装,并指定目录
yum install tree -y --downloadonly --downloaddir=/tmp
--downloadonly:仅下载,不安装
--downloaddir:指定下载的目录
# yum clean packages
只会清除默认路径下的包
举例
[root@zxw < /sub> ]# find /var/cache/yum/ -type f -name *.rpm
/var/cache/yum/x86_64/7/base/packages/tree-1.6.0-10.el7.x86_64.rpm
[root@zxw < sub> ]# ll /tmp
total 56
-rw-r--r--. 1 root root 47508 Jul42014 tree-1.6.0-10.el7.x86_64.rpm
-rw-------. 1 root root236 Apr 24 15:31 yum_save_tx.2022-04-24.15-31._nKsFC.yumtx
-rw-------. 1 root root236 Apr 24 15:32 yum_save_tx.2022-04-24.15-32.KhBb_m.yumtx
[root@zxw < /sub> ]# yum clean packages
Loaded plugins: fastestmirror
Cleaning repos: base epel extras nginx-stable updates
1 package file removed
[root@zxw < sub> ]# find /var/cache/yum/ -type f -name *.rpm
[root@zxw < /sub> ]# ll /tmp
total 56
-rw-r--r--. 1 root root 47508 Jul42014 tree-1.6.0-10.el7.x86_64.rpm
-rw-------. 1 root root236 Apr 24 15:31 yum_save_tx.2022-04-24.15-31._nKsFC.yumtx
-rw-------. 1 root root236 Apr 24 15:32 yum_save_tx.2022-04-24.15-32.KhBb_m.yumtx
yum包组管理命令
# 查看有哪些包组可以安装
[root@zxw ~]# yum group list
# 安装包组
yum groups install 包组名字
# 卸载包组
yum groups remove 包组名字
(# 没太大必要,应为最开始安装系统的时候选择的是最小化安装,安装其他的包组反而麻烦)
[root@zxw ~]# yum group list
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Cinnamon Desktop
MATE Desktop
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Cinnamon
Compatibility Libraries
Console Internet Tools
Development Tools
Educational Software
Electronic Lab
Fedora Packager
General Purpose Desktop
Graphical Administration Tools
Haskell
LXQt Desktop
Legacy UNIX Compatibility
MATE
Milkymist
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
TurboGears application framework
Xfce
Done
yum历史命令
# 查看yum的历史操作
[root@zxw < sub> ]# yum history
Loaded plugins: fastestmirror
命令的ID执行的命令执行的时间动作操作几个包
ID| Login user| Date and time| Action(s)| Altered
-------------------------------------------------------------------------------
9 | root < root> | 2022-04-24 16:06 | Erase|1
8 | root < root> | 2022-04-24 15:38 | Install|1
7 | root < root> | 2022-04-24 15:28 | Erase|1
6 | root < root> | 2022-04-23 21:57 | Update|1
5 | root < root> | 2022-04-23推荐阅读
- Redis主从故障模拟及恢复
- 自制yum仓库
- ceph基于VMware Workstation虚拟机Ceph集群安装配置笔记#私藏项目实操分享#
- 如何使用maven把项目及其依赖打包为可运行jar包
- ROS 2.0-SPRINGER-机器人学工具科研和教学重要参考书-机器人操作系统(ROS)-THE COMPLETE REFERENCE
- Prometheus监控K8S各项指标
- linux之service命令
- 云原生应用配置中心简述
- 如何修复Windows更新错误8024402c(解决办法分步指南)