Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is it like to roll back the upgrade operation using the YUM history command on a RHEL/CentOS system

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In view of what it is like to roll back the upgrade operation using the YUM history command on the RHEL/CentOS system, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find an easier way.

Patching servers is an important task for Linux system administrators in order to make the system more stable and performance optimized. Manufacturers often release some security / high-risk patches, and the relevant software needs to be upgraded to guard against potential security risks.

Yum (Yellowdog Update Modified) is a RPM package management tool used on CentOS and RedHat systems. The yum history command allows the system administrator to roll back the system to the previous state, but due to some limitations, the rollback is not successful in all cases. Sometimes the yum command may do nothing and sometimes delete some other packages.

I suggest you make a full system backup before upgrading, and yum history cannot be used as a substitute for system backup. System backup allows you to restore the system to the node state at any time.

In some cases, what if the installed application does not work properly after upgrading the patch or has some errors (perhaps due to library incompatibility or package upgrades)?

Communicate with the application development team and identify the problems that are causing the libraries and packages, and then use the yum history command to roll back.

Note:

It does not support rollback of selinux,selinux-policy-*,kernel,glibc (and packages that depend on glibc, such as gcc).

Downgrading the system to a lower version (such as CentOS 6.9 to CentOS 6.8) is not recommended, which can cause the system to be in an unstable state.

Let's first see which packages can be upgraded on the system, and then pick out some packages to experiment with.

# yum updateLoaded plugins: fastestmirror SecuritySetting up Update ProcessLoading mirror speeds from cached hostfileepel/metalink | 12 kB 00:00 * epel: mirror.csclub.uwaterloo.cabase | 3.7 kB 00:00dockerrepo | 2.9 kB 00:00draios | 2.9 kB 00:00draios/primary_db | 13 kB 00:00epel | 4.3 kB 00:00epel/primary_db | 5.9 MB 00:00extras | 3.4 kB 00:00updates | 3.4 kB 00:00updates/primary_db | 2.5 MB 00:00Resolving Dependencies-- > Running transaction check--- > Package git.x86_64 0VOR 1.7.1-8.el6 will be updated--- > Package git.x86_64 0VR 1.7.1-9.el6_9 will be an update--- > Package httpd.x86_64 0VOR 2.2.15-60.el6.centos.4 will be updated--- > Package httpd.x86_64 0VOR 2.2.15-60.el6.centos.5 will be an update--- > Package httpd-tools.x86_64 0:2. 2.15-60.el6.centos.4 will be updated--- > Package httpd-tools.x86_64 0VOR 2.2.15-60.el6.centos.5 will be an update--- > Package perl-Git.noarch 0VOR 1.7.1-8.el6 will be updated--- > Package perl-Git.noarch 0VR 1.7.1-9.el6_9 will be an update-- > Finished Dependency Resolution Dependencies Resolved = Package Arch Version Repository Size=Updating: git x86v 64 1.7.1 -9.el6_9 updates 4.6m httpd x861364 2.2.15-60.el6.centos.5 updates 836k httpd-tools x861662.15-60.el6.centos.5 updates 80k perl-Git noarch 1.7.1-9.el6_9 updates 29k Transaction Summary=Upgrade 4 Package (s) Total download size: 5.5MIs this ok [y Total download size N]: n

You will find that the git package can be upgraded, so let's experiment with it. Run the following command to get the version information of the package (the currently installed version and the version that can be upgraded).

# yum list gitLoaded plugins: fastestmirror, securitySetting up Update ProcessLoading mirror speeds from cached hostfile * epel: mirror.csclub.uwaterloo.caInstalled Packagesgit.x86_64 1.7.1-8.el6 @ baseAvailable Packagesgit.x86_64 1.7.1-9.el6_9 updates

Run the following command to upgrade git from 1.7.1-8 to 1.7.1-9.

# yum update gitLoaded plugins: fastestmirror PrestoSetting up Update ProcessLoading mirror speeds from cached hostfile * base: repos.lax.quadranet.com * epel: fedora.mirrors.pair.com * extras: mirrors.seas.harvard.edu * updates: mirror.sesp.northwestern.eduResolving Dependencies-- > Running transaction check--- > Package git.x86_64 0vir 1.7.1-8.el6 will be updated-- > Processing Dependency: git = 1.7.1-8.el6 for package: perl-Git-1.7.1-8.el6.noarchMurray-> Package Git.x86_64 0VOR 1.7.1-9.el6_9 will be an update-- > Running transaction check--- > Package perl-Git.noarch 0VR 1.7.1-8.el6 will be updated--- > Package perl-Git.noarch 0V 1.7.1-9.el6_9 will be an update-- > Finished Dependency Resolution Dependencies Resolved = Package Arch Version Repository Size=Updating: git x86mm 64 1.7.1-9.el6_9 updates 4.6 MUpdating for dependencies: perl-Git Noarch 1.7.1-9.el6_9 updates 29k Transaction Summary=Upgrade 2 Package (s) Total download size: 4.6MIs this ok [y MB N]: yDownloading Packages:Setting up and reading Presto delta metadataProcessing delta metadataPackage (s) data still to download: 4.6m (1max 2): git-1.7.1-9.el6_9.x86_64.rpm | 4.6MB 00:00 (2max 2): perl-Git-1.7.1-9.el6_9.noarch.rpm | | 29 kB 00:00-Total 5.8 MB/s | 4.6 MB 00:00Running rpm_ | Check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Updating: perl-Git-1.7.1-9.el6_9.noarch 1 Cleanup 4 Updating: git-1.7.1-9.el6_9.x86_64 2 Cleanup 4 Cleanup: perl-Git-1.7.1-8.el6.noarch 3 Cleanup 4 Cleanup: git-1.7.1-8.el6.x86_64 4 Verifying: git-1.7.1-9.el6_9.x86_64 1 Cleanup 4 Verifying: perl-Git- 1.7.1-9.el6_9.noarch 2 9.el6_9 Dependency Updated 4 Verifying: git-1.7.1-8.el6.x86_64 3 Verifying 4 Verifying: perl-Git-1.7.1-8.el6.noarch 4 Updated: git.x86_64 0 Vera 1.7.1-9.el6_9 Dependency Updated: perl-Git.noarch 0 git-1.7.1 1.7.1-9.el6_9 Complete!

Verify the upgraded git version.

# yum list gitInstalled Packagesgit.x86_64 1.7.1-9.el6_9 @ updates or # rpm-Q gitgit-1.7.1-9.el6_9.x86_64

Now that we have successfully upgraded the package, we can roll it back. The steps are as follows.

Use the YUM history command to roll back the upgrade operation

First, get the id of the yum operation using the following command. The following output clearly lists all the required information, such as the operation id, who did the operation (user name), the date and time of the operation, the action of the operation (installation or upgrade), and the number of packages affected by the operation.

# yum history or # yum history list allLoaded plugins: fastestmirror PrestoID | Login user | Date and time | Action (s) | Altered---- 13 | root | 2017-08-18 13:30 | Update | 2 12 | root | 2017-08-10 07 : 46 | Install | 1 11 | root | 2017-07-28 17:10 | E I, U | 28 EE 10 | root | 2017-04-21 09:16 | E, I, U | 2017-02-09 17:09 | E, I, U | 20 EE 8 | root | 2017-02-02 10:45 | Install | 17 | root | 2016-12-15 06:48 | Update | 16 | root | 2016-12-15 06:43 | Install | 15 | root | 2016-12-02 10:28 | E, I, U | 23 EE 4 | root | 2016-10-28 05:37 | E | I, U | 13 EE 3 | root | 2016-10-18 12:53 | Install | 12 | root | 2016-09-30 10:28 | E, I, U | 31 EE 1 | root | 2016-07-26 11:40 | E, I, U | 160 EE

The above command shows that two packages are affected because git also upgraded its dependency package, perl-Git. Run the following command to view details about the operation.

# yum history info 13Loaded plugins: fastestmirror PrestoTransaction ID: 13Begin time: Fri Aug 18 13:30:52 2017Begin rpmdb: 420:f5c5f9184f44cf317de64d3a35199e894ad71188End time: 13:30:54 2017 (2 seconds) End rpmdb: 420:d04a95c25d4526ef87598f0dcaec66d3f99b98d4User: rootReturn-Code: update gitTransaction performed with: Installed rpm-4.8.0-55.el6.x86_64 @ base Installed yum-3.2.29-81.el6.centos.noarch @ base Installed yum-plugin-fastestmirror-1.1.30-40.el6.noarch @ base Installed yum-presto-0.6.2-1. El6.noarch @ anaconda-CentOS-201207061011.x86_64/6.3Packages Altered: Updated git-1.7.1-8.el6.x86_64 @ base Update 1.7.1-9.el6_9.x86_64 @ updates Updated perl-Git-1.7.1-8.el6.noarch @ base Update 1.7.1-9.el6_9.noarch @ updateshistory info

Run the following command to roll back the git package to the previous version.

# yum history undo 13Loaded plugins: fastestmirror, prestoUndoing transaction 53 From Fri Aug 18 13:30:52 2017 Updated git-1.7.1-8.el6.x86_64 @ base Update 1.7.1-9.el6_9.x86_64 @ updates Updated perl-Git-1.7.1-8.el6.noarch @ base Update 1.7.1-9.el6_9.noarch @ updatesLoading mirror speeds from cached hostfile * base: repos.lax.quadranet.com * epel: fedora.mirrors.pair.com * extras: repo1.dal.innoscale.net * updates: mirror Vtti.vt.eduResolving Dependencies-- > Running transaction check--- > Package git.x86_64 0vir 1.7.1-8.el6 will be a downgrade--- > Package git.x86_64 0vir 1.7.1-9.el6_9 will be erased--- > Package perl-Git.noarch 0vir 1.7.1-8.el6 will be a downgrade--- > Package perl-Git.noarch 0vir 1.7.1-9.el6_9 will be erased-- > Finished Dependency Resolution Dependencies Resolved = Package Arch Version Repository Size=Downgrading: git x86 * 64 1.7.1-8.el6 base 4.6m perl-Git noarch 1.7.1-8.el6 base 29k Transaction Summary=Downgrade 2 Package (s) Total download size: 4.6MIs this ok [y data still to download N]: yDownloading Packages:Setting up and reading Presto delta metadataProcessing delta metadataPackage (s) data still to download: 4.6m (1MIs this ok 2): git-1.7.1-8.el6.x86_64.rpm | 4.6 MB 00: 00 (2max 2): perl-Git-1.7.1-8.el6.noarch.rpm | 29 kB 0000- -Total 3. 4 MB/s | 4. 6 MB 00:01Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing: perl-Git-1.7.1-8.el6.noarch 1 8.el6.x86_64 4 Installing: git-1.7.1-8.el6.x86_64 2 8.el6.x86_64 4 Cleanup: perl-Git-1.7.1-9.el6_9.noarch 3 8.el6.x86_64 4 Cleanup: git-1.7.1-9.el6_9.x86_64 4 git-1.7.1: git- 4 Verifying: git- 1.7.1-8.el6.x86_64 1 9.el6_9.noarch 4 Verifying: perl-Git-1.7.1-8.el6.noarch 2 Verifying 4 Verifying: git-1.7.1-9.el6_9.x86_64 3 Verifying 4 Verifying: perl-Git-1.7.1-9.el6_9.noarch 4 9.el6_9.noarch 4 Removed: git.x86_64 0Vera 1.7.1-9.el6_9 perl-Git.noarch 0Vera 1.7.1-9.el6_9 Installed: Git.x86_64 0vl. 7. 1-8.el6 perl-Git.noarch 0. 1. 7. 1-8.el6 Complete!

After the rollback, use the following command to check the version of the degraded package.

# yum list git or # rpm-Q gitgit-1.7.1-8.el6.x86_64 rollback the upgrade using the YUM downgrade command

Alternatively, we can roll back the upgrade using the YUM downgrade command.

# yum downgrade git-1.7.1-8.el6 perl-Git-1.7.1-8.el6Loaded plugins: search-disabled-repos, security UlninfoSetting up Downgrade ProcessResolving Dependencies-- > Running transaction check--- > Package git.x86_64 0vir 1.7.1-8.el6 will be a downgrade--- > Package git.x86_64 0vir 1.7.1-9.el6_9 will be erased--- > Package perl-Git.noarch 0vir 1.7.1-8.el6 will be a downgrade--- > Package perl-Git.noarch 0vir 1.7.1-9.el6_9 will be erased-- > Finished Dependency Resolution Dependencies Resolved = Package Arch Version Repository Size=Downgrading: git x86ip64 1.7.1-8.el6 base 4.6m perl-Git noarch 1.7.1-8.el6 base 29k Transaction Summary=Downgrade 2 Package (s) Total download size: 4.6MIs this ok [y Transaction Summary=Downgrade N]: yDownloading Packages: (1MIs this ok 2): git-1.7.1-8.el6.x86_64.rpm | 4.6MB 00:00 (2amp 2): perl-Git-1.7.1-8.el6.noarch .rpm | 28 kB 00:00-Total 3.7 MB/s | 4.6 MB 00:01Running Rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing: perl-Git-1.7.1-8.el6.noarch 1 Cleanup 4 Installing: git-1.7.1-8.el6.x86_64 2 Cleanup 4 Cleanup: perl-Git-1.7.1-9.el6_9.noarch 3 Cleanup 4 Cleanup: git-1.7.1-9.el6_9.x86_64 4 Verifying: git-1.7.1-8.el6.x86_64 1 Cleanup 4 Verifying: perl-Git- 1.7.1-8.el6.noarch 2 9.el6_9 perl-Git.noarch 4 Verifying: git-1.7.1-9.el6_9.x86_64 3 Verifying 4 Verifying: perl-Git-1.7.1-9.el6_9.noarch 4 Removed: git.x86_64 0VV 1.7.1-9.el6_9 perl-Git.noarch 0V1 1.7.1-9.el6_9 Installed: git.x86_64 0VV 1.7.1-8.el6 perl-Git.noarch 0VLA 1.7.1-8.el6 Complete!

Note: you also need to downgrade the dependency package, otherwise it will delete the current version of the dependency package instead of downgrading the dependency package, because the downgrade command cannot handle dependencies.

As for Fedora users

The command is the same, just change the package manager name from yum to dnf.

# dnf list git# dnf history# dnf history info# dnf history undo# dnf list git# dnf downgrade git-1.7.1-8.el6 perl-Git-1.7.1-8.el6 the answer to the question about how to roll back the upgrade operation using the YUM history command on the RHEL/CentOS system is shared here. I hope the above content can be of some help to you, if you still have a lot of questions to solve. You can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 290

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report