RHEL - 更新升级软件或系统

本文详细介绍了在RHEL系统中使用yum工具进行小版本软件更新(yumupdate和yumupgrade的区别)、升级软件与系统、检查软件包更新、指定发行版本、查看升级类型和安全更新,还包括了查看升级历史、撤销和回滚操作,以及大版本系统升级的参考资源。
摘要由CSDN通过智能技术生成

OpenShift / RHEL / DevSecOps 汇总目录

说明:先《RHEL - 订阅、注册系统和 Yum Repository》一文完成 “注册和注销 RHEL 系统” 章节。

小版本软件更新

yum update 和 yum upgrade 的区别

yum update 和 yum upgrade 都会升级软件,唯一的区别是 yum update 使用了 –obsolete flage=0 参数,而 yum upgrade 使用了 –obsolete flage=1 的参数。

yum update 是直接将旧版本软件升级到新版本,因此升级后还会继续保留有些不再被用的旧版文件,而 yum upgrade 是先把旧版本的软件删除后再安装新版软件。

升级软件和升级系统

以下命令分别会升级 rpm 软件和整个系统。

$ yum update rpm
$ yum update

检查软件包是否可升级

只检查软件包是否可用的升级。

$ yum check-update rpm
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.

rpm.x86_64                      4.11.3-48.el7_9                         rhel-7-server-rpms

指定升级软件使用的发行版本

可以使用以下显式(前一种)或隐式(后三种)的方法指定 yum 命令使用的发行版本。
注意:如果以下方法都不用,则缺省会使用当前主要版本的最新次要版本,例如 7.9。另外显式方法可以覆盖隐式方法所指定的版本。

方法1

  1. 执行命令检查可更新的 kernel,在参命令参数中显式指定使用的发行版本,
$ yum check-update kernel --releasever=7.6

方法2

注意:该方法只能将使用的版本锁定在当前环境中 redhat-release-server 包所对应的版本。

  1. 在 /etc/yum.conf 文件中添加以下内容。
distroverpkg=redhat-release-server
  1. 然后检查可更新的 kernel。
$ yum check-update kernel

方法3

  1. 执行命令,在 /etc/yum/vars/releasever 文件中设置使用的发行版本,然后检查可更新的 kernel。
$ echo 7.8 > /etc/yum/vars/releasever
$ yum check-update kernel

方法4

  1. 参照《RHEL - 订阅、注册系统和 Yum Repository》一文的 “将 RHEL 系统关联和取关订阅” 章节完成订阅关联。
  2. 执行以下命令设置使用的发行版本,然后检查可更新的 kernel。
$ subscription-manager release --show
Release not set

$ subscription-manager release --set=7.6
Release set to: 7.6

$ yum check-update kernel

查看软件升级类型

  1. 以下命令可以列出和当前环境有关的所有可用软件更新包:
$ yum updateinfo list
  1. 还可进一步查看升级包类型,包括 RHSA/RHBA/RHEA。
$ yum updateinfo list --security
$ yum updateinfo list --bugfix
$ yum updateinfo list | grep enhancement

更新升级指定的 RHSA/RHBA/RHEA

$ yum update --advisory=RHSA-2022:6834

更新升级指定的 CVE

$ yum updateinfo list cves
$ yum update --cves=CVE-2022-40674

更新升级指定的 Bug

可以通过 https://access.redhat.com/errata/RHBA-2022:6936 查看一个 RHBA 对应的 Bug 编号,然后使用该编号升级。

$ yum update --bz=2130769

查看软件安装升级操作历史

  1. 先安装一个软件,然后查看操作历史。
$ yum install createrepo
$ yum history
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     2 | root <root>              | 2024-01-11 12:01 | Install        |    3
     1 | System <unset>           | 2023-10-16 02:32 | Install        |  342
  1. 查看 ID 为 2 的详细情况。
$ yum history info 2
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is registered with an entitlement server, but is not receiving updates. You can use subscription-manager to assign subscriptions.
Transaction ID : 2
Begin time     : Thu Jan 11 12:01:18 2024
Begin rpmdb    : 342:c938f565466bf7a9c8b9740a0504053f5f0b5922
End time       :            12:01:24 2024 (6 seconds)
End rpmdb      : 345:58ca1f49bd20bfca9e08468a8514a7f9fd62e525
User           : root <root>
Return-Code    : Success
Command Line   : install createrepo
Transaction performed with:
    Installed     rpm-4.11.3-35.el7.x86_64                  @anaconda/7.6
    Installed     subscription-manager-1.21.10-2.el7.x86_64 @anaconda/7.6
    Installed     yum-3.4.3-161.el7.noarch                  @anaconda/7.6
Packages Altered:
    Install     createrepo-0.9.9-28.el7.noarch   @rhel-7-server-rpms
    Dep-Install deltarpm-3.6-3.el7.x86_64        @rhel-7-server-rpms
    Dep-Install python-deltarpm-3.6-3.el7.x86_64 @rhel-7-server-rpms
history info

undo/rollback 操作

yum history 的 undo 将撤销一个指定的操作事务,而 rollback 将回滚指定事务之后的所有操作事务。

  1. 以下命令是撤销 ID 为 2 的操作。
$ yum history undo 2
  1. 以下命令是撤销 ID 为 1 以后的所有操作,即恢复到 ID 为 1 时的状态。
$ yum history rollback 1

大版本系统升级

参见 https://access.redhat.com/labs/rhelupgradehelper,可根据向导可获得跨大版本升级 RHEL 的操作指导。
在这里插入图片描述

参考

https://access.redhat.com/solutions/238533
https://access.redhat.com/solutions/10021
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-yum
https://linuxsimply.com/linux-basics/package-management/upgrade-package/yum-update-vs-upgrade/
https://access.redhat.com/downloads/content/69/ver=/rhel—7/7.9/x86_64/product-errata
https://git.centos.org/rpms/kernel/releases
https://kcm.trellix.com/corporate/index?page=content&id=KB93176
https://www.redhat.com/zh/blog/what-latest-kernel-release-my-version-red-hat-enterprise-linux
https://access.redhat.com/articles/3078

  • 18
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值