LoginSignup
5
4

More than 5 years have passed since last update.

yum historyとrpm -qa --lastで、構築手順を追跡

Posted at

「前任者が残した手順通りだとうまくいかない!」という時のtipsです。

あってはならないことですが、そういうことほどよくありますよね…
そんなとき、実際に行われた手順を探るために、yum historyとrpmが使えます。

yum history

実行すると、下記のように、yumの実行ユーザ、実行日時、Install,Update,Eraseが行われたか、変更したパッケージ数が一覧で表示されます。

[vagrant@repo ~]$ sudo yum history
Loaded plugins: fastestmirror
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     5 |  <vagrant>               | 2015-11-13 13:54 | Install        |    1
     4 |  <vagrant>               | 2015-11-13 13:44 | I, U           |  144
     3 |  <vagrant>               | 2015-11-13 13:44 | Erase          |    1
     2 |  <vagrant>               | 2015-11-13 13:42 | I, U           |    2
     1 | System <unset>           | 2015-10-28 11:16 | Install        |  199
history list

yum history info <ID> で、該当IDの詳細が下記のようにでてきます。

[vagrant@repo ~]$ sudo yum history info 5
Loaded plugins: fastestmirror
Transaction ID : 5
Begin time     : Fri Nov 13 13:54:15 2015
Begin rpmdb    : 321:5330737f69efda14820e80fff65404d230f6100a
End time       :                           (0 seconds)
End rpmdb      : 322:a473b48264c41cba95677f27998bd4a84a26a386
User           :  <vagrant>
Return-Code    : Success
Command Line   : install unzip
Transaction performed with:
    Installed     rpm-4.8.0-32.el6.x86_64                       @anaconda-CentOS-201303020151.x86_64/6.4
    Installed     yum-3.2.29-40.el6.centos.noarch               @anaconda-CentOS-201303020151.x86_64/6.4
    Installed     yum-plugin-fastestmirror-1.1.30-14.el6.noarch @anaconda-CentOS-201303020151.x86_64/6.4
Packages Altered:
    Install unzip-6.0-2.el6_6.x86_64 @base
history info

yum localinstall *.rpm と実行した場合、Command lineでは該当するrpmファイルが、次のような感じで全て表示されます。

yum localinstall xxx.rpm yyy.rpm ... zzz.rpm

これらの情報があれば、いつ、何をいれて何を削ったのかがわかります。
よくわからずに、何回か色々やったらできるようになった、というときも、これで見直して一回でうまく組み合わせ・手順にまとめ直すこともできるでしょう。

rpm -qa --last

実行すると、現在インストールされているパッケージ全てと、それらがインストール(or アップデート)された時刻が下記のように表示されます。作業者がやる前から入っていたのかどうかの判断材料になるでしょう。

[vagrant@repo ~]$ rpm -qa --last
unzip-6.0-2.el6_6.x86_64                      2015年11月13日 13時54分15秒
gpg-pubkey-c105b9de-4e0fd3a3                  2015年11月13日 13時54分04秒
mlocate-0.22.2-4.el6.x86_64                   2015年11月13日 13時46分19秒
libmemcached-0.31-1.1.el6.x86_64              2015年11月13日 13時46分18秒
libffi-devel-3.0.5-3.2.el6.x86_64             2015年11月13日 13時46分18秒
sqlite-devel-3.6.20-1.el6.x86_64              2015年11月13日 13時46分17秒
libxml2-python-2.7.6-17.el6_6.1.x86_64        2015年11月13日 13時46分17秒
patch-2.6-6.el6.x86_64                        2015年11月13日 13時46分16秒
libselinux-utils-2.0.94-5.8.el6.x86_64        2015年11月13日 13時46分16秒

また、rpm -q <パッケージ名> --last で、対象をそのパッケージに限定できます。

[vagrant@repo ~]$ rpm -q unzip --last
unzip-6.0-2.el6_6.x86_64

インストールされていないときは、こんな感じです。

[vagrant@repo ~]$ rpm -q wget --last
パッケージ                                         wget はインストールされていません。
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4