RHEL7: Use yum transaction history.

Share this link

Presentation

Since yum version 3.2.25 (already available in RHEL 6), it is possible to play with a transaction history.
To start with, all package installation or removal operations are recorded in the rpmdb.

To display the rpmdb version, type:

# yum version
Loaded plugins: fastestmirror, langpacks
Installed: 7/x86_64                 539:c8c53419da0ae4cba61f019df443d3c10593a208
Group-Installed: yum                 14:d92850d928d628772a0a1d95c98e078545b0eea0
version

The information in bold represents the rpmdb version. If two servers have got the same rpmdb version, there are strictly identical from a yum point of view.

Transaction history

Then, it can be interesting to know which operations were previously done: it is the main purpose of the transaction history.

To get the last yum operation done, type:

# yum history info
Loaded plugins: fastestmirror, langpacks
Transaction ID : 12
Begin time     : Mon Nov 10 11:28:01 2014
Begin rpmdb    : 538:541464668d769a2bb7dbfc8337e305ab6db9fb47
End time       :            11:28:03 2014 (2 seconds)
End rpmdb      : 539:c8c53419da0ae4cba61f019df443d3c10593a208
User           : root 
Return-Code    : Success
Command Line   : install setools-console
Transaction performed with:
    Installed     rpm-4.11.1-16.el7.x86_64                        @anaconda
    Installed     yum-3.4.3-118.el7.centos.noarch                 @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-25.el7_0.noarch @updates
Packages Altered:
    Install setools-console-3.3.7-46.el7.x86_64 @base
history info

Here, you can see that the setools-console package was installed. You can also see the rpmdb version before and after the operation, the date, the time taken by the installation and the status of the operation (success/failure).

To get the list of all the previous yum recorded operations, type:

# yum history list all
Loaded plugins: fastestmirror, langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    12 | root <root>              | 2014-11-10 11:28 | Install        |    1
    11 | root <root>              | 2014-11-01 06:22 | Install        |    5
    10 | root <root>              | 2014-11-01 06:21 | Install        |    7
     9 | root <root>              | 2014-11-01 06:04 | Install        |    7
     8 | root <root>              | 2014-11-01 06:00 | Install        |    5
     7 | root <root>              | 2014-10-29 17:12 | Install        |    2
     6 | root <root>              | 2014-10-29 16:02 | Install        |    9
     5 | root <root>              | 2014-10-29 15:39 | Install        |   37
     4 | root <root>              | 2014-10-27 08:58 | Update         |   14
     3 | root <root>              | 2014-10-16 10:01 | I, U           |   47
     2 | root <root>              | 2014-09-05 15:32 | I, U           |   49
     1 | System <unset>           | 2014-07-19 13:39 | Install        |  464
history list

Note1: The Altered column represents the number of modified packages.
Note2: If you don’t specify the all option, you get the twenty most recent operations.
Note3: The yum history command reads the /var/log/yum.log file.

To get the details of one of these operations (here the operation called 9), type:

# yum history list 9
Loaded plugins: fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     9 | install gcc              | 2014-11-01 06:04 | Install        |    7
history list

To get even more details about one of the operations (here the operation called 12), type:

# yum history info 12
Loaded plugins: fastestmirror, langpacks
Transaction ID : 12
Begin time     : Mon Nov 10 11:28:01 2014
Begin rpmdb    : 538:541464668d769a2bb7dbfc8337e305ab6db9fb47
End time       :            11:28:03 2014 (2 seconds)
End rpmdb      : 539:c8c53419da0ae4cba61f019df443d3c10593a208
User           : root 
Return-Code    : Success
Command Line   : install setools-console
Transaction performed with:
    Installed     rpm-4.11.1-16.el7.x86_64                        @anaconda
    Installed     yum-3.4.3-118.el7.centos.noarch                 @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-25.el7_0.noarch @updates
Packages Altered:
    Install setools-console-3.3.7-46.el7.x86_64 @base
history info

To get the list of all the previous yum recorded operations organized by date, type:

# yum history summary
Loaded plugins: fastestmirror, langpacks
Login user                 | Time                | Action(s)        | Altered
-------------------------------------------------------------------------------
root <root>                | Last day            | E, I             |        3
root <root>                | Last 2 weeks        | Install          |       72
root <root>                | Last 3 months       | I, U             |      110
System <unset>             | Last 6 months       | Install          |      464
history summary

Note: To get the list of all the previous package installations sorted per date, type:
# rpm -qa –last

To get all the operations concerning a specific package (here the kernel package), type:

# yum history list kernel
Loaded plugins: fastestmirror, langpacks
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     3 | root <root>              | 2014-10-16 10:01 | I, U           |   47
     2 | root <root>              | 2014-09-05 15:32 | I, U           |   49
     1 | System <unset>           | 2014-07-19 13:39 | Install        |  464
history list

To get the details of the operations concerning a specific package (here the kernel package), type:

# yum history package-list kernel
Loaded plugins: fastestmirror, langpacks
ID     | Action(s)      | Package
-------------------------------------------------------------------------------
     3 | Install        | kernel-3.10.0-123.8.1.el7.x86_64
     2 | Install        | kernel-3.10.0-123.6.3.el7.x86_64
     1 | Install        | kernel-3.10.0-123.el7.x86_64
history package-list

Transaction history changes

In the transaction history expression, you can find the transaction term. This means that you can undo and redo each and every yum previously recorded operation, even though multiple packages were involved (you still have to be careful with glibc or selinux-policy packages that have very complicated dependencies).

To undo the last operation, type:

# yum history undo last
Loaded plugins: fastestmirror, langpacks
Undoing transaction 12, from Mon Nov 10 11:28:01 2014
    Install setools-console-3.3.7-46.el7.x86_64 @base
Resolving Dependencies
--> Running transaction check
---> Package setools-console.x86_64 0:3.3.7-46.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch          Version                Repository    Size
================================================================================
Removing:
 setools-console        x86_64        3.3.7-46.el7           @base        1.1 M

Transaction Summary
================================================================================
Remove  1 Package

Installed size: 1.1 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : setools-console-3.3.7-46.el7.x86_64                          1/1
  Verifying  : setools-console-3.3.7-46.el7.x86_64                          1/1

Removed:
  setools-console.x86_64 0:3.3.7-46.el7

Complete!

To display the transaction history concerning the setools-console package, type:

# yum history list setools-console
Loaded plugins: fastestmirror, langpacks
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    13 | history undo last        | 2014-11-10 18:12 | Erase          |    1
    12 | install setools-console  | 2014-11-10 11:28 | Install        |    1
history list

To re-install the setools-console package (the operation called 12), type:

# yum history redo 12

Use of rpm

To keep a clean history, you should avoid the use of the rpm command as much as possible because it breaks the transaction history.

For example, here is a transaction history:

# yum history
Loaded plugins: fastestmirror, langpacks
ID     | Login user        | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     2 | root              | 2014-11-21 16:18 | I, U           |   85
     1 | System            | 2014-11-21 14:14 | Install        |  464
history list

A new package (here zlib-devel) is installed via the rpm command:

# rpm -ivh zlib-devel-1.2.7-13.el7.x86_64.rpm

Later on, a global package update is run:

# yum update
...
Warning: RPMDB altered outside of yum.
...

Now, if we ask for the transaction history, we get:

# yum history
Loaded plugins: fastestmirror, langpacks
ID     | Login user        | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     3 | root              | 2014-11-25 11:15 | I, U           |   31  <
     2 | root              | 2014-11-21 16:18 | I, U           |   85 >
     1 | System            | 2014-11-21 14:14 | Install        |  464
history list

The < and > signs displayed show that some information has been lost (the package installed via the rpm command has no associated information).

There is no way to fix this problem. Your only option is to clear the transaction history and hide all the previous yum operations. To do that, type:

# yum history new

To avoid this problem, you can type:

# yum install zlib-devel
or
# yum install /path/to/zlib-devel-1.2.7-13.el7.x86_64.rpm

Transaction recovery

If during an upgrade your system goes down when restarted, type:

# yum-complete-transaction

This command searches for incomplete or aborted yum transactions on a system and attempts to complete them.

Source: RHEL 6 Deployment Guide.

Additional Resources

You can also watch Andrew Mallett‘s video about Yum History (2min/2016).

(3 votes, average: 4.67 out of 5)
Loading...

Leave a Reply

Upcoming Events (Local Time)

There are no events.

Follow me on Twitter

Archives

vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |