欢迎来到之路教程(on itroad-com)
回滚 RPM 卸载
让我们看一个回滚卸载软件包的示例 (firefox)。
- 检查之前安装的firefox版本:
# rpm -qa | grep -i firefox firefox-52.0-5.el7_3.x86_64 ======> Current version of rpm
- 现在删除firefox包
# yum remove firefox
- 现在使用命令 yum history 检查所有过去的 yum 交易:
# yum history Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------ 20 | root [root] | 2017-05-24 09:48 | Erase | 1 ====> the firefox rpm removed here 19 | root [root] | 2017-05-24 09:47 | I, U | 14 18 | root [root] | 2017-05-05 07:13 | Install | 1 < 17 | System [unset] | 2016-12-27 16:46 | Update | 2 > 16 | root [root] | 2016-10-19 16:02 | Install | 1 < 15 | root [root] | 2016-05-14 14:18 | Install | 1 > 14 | root [root] | 2016-05-14 13:52 | Install | 4 13 | root [root] | 2016-05-14 13:37 | Install | 2 history list
- 现在使用 yum history undo 命令回滚包的卸载。
请注意 firefox 包卸载事务的事务 ID 20。
最新的事务总是在表格的顶部。
# yum history undo 20 Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager ... Installed size: 150 M Is this ok [y/d/N]: y Downloading packages: firefox-52.0-5.el7_3.x86_64.rpm | 83 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : firefox-52.0-5.el7_3.x86_64 1/1 Verifying : firefox-52.0-5.el7_3.x86_64 1/1 Installed: firefox.x86_64 0:52.0-5.el7_3 Complete!
- 上述命令回滚前一个交易。
我们现在可以检查 Firefox rpm。
我们应该获得与之前安装的完全相同的版本。
# rpm -qa | grep -i firefox firefox-52.0-5.el7_3.x86_64
始终建议在任何更新之前进行完整的系统备份,并且 yum history 并不意味着替换系统备份。
注意:不支持将 selinux、selinux-policy-*、kernel、glibc(glibc 的依赖项,例如 gcc)包回滚到旧版本。
因此,不建议将系统降级到次要版本(例如:RHEL6.6 到 RHEL6.5),因为这可能会使系统处于不希望的状态。
使用 yum history 选项进行小的更新回滚。
yum 如何存储事务历史
yum 存储有关每个事务的信息的 sqlite 数据库。
历史是有组织的事务 id 条款,每次 yum 事务影响系统的包配置时都会更新。
大多数情况下,这个数据库可以在 /var/lib/yum/history/ 目录中找到。
“yum history”命令允许用户查看交易历史。
以下命令列出所有交易的历史记录:
# yum history list all
这将列出交易 ID 以及日期和时间、执行的操作以及更改的软件包数量。
有关特定交易的更多信息,请记下该交易的交易 ID 并在以下命令中使用它:
# yum history info [transaction_ID]
日期:2020-09-17 00:12:40 来源:oir作者:oir