9.4. トランザクション履歴の活用
yum history コマンドを使用すると、Yum のトランザクションのタイムライン、トランザクションの発生日時、影響を受けたパッケージ数、トランザクション成功の有無、RPM データベースがトランザクション間で変更されたかどうかといった情報を確認することができます。さらに、このコマンドを使うと、特定のトランザクションを元に戻す、やり直すことが可能です。すべての履歴データは、/var/lib/yum/history/ ディレクトリーの history DB に保存されます。
9.4.1. トランザクションの一覧表示
root で引数なしで yum history を実行するか、シェルプロンプトで以下を入力します。
yumhistorylist
all のキーワードを追加します。
yumhistorylistall
yumhistoryliststart_id..end_id
yumhistorylistglob_expression…
例9.19 最も古いトランザクション 5 件を表示する
yum history list の出力では、最新のトランザクションがリストの上部に表示されます。履歴データベースにある最も古い 5 件のトランザクションに関する情報を表示するには、以下を入力します。
~]# yum history list 1..5
Loaded plugins: langpacks, product-id, subscription-manager
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
5 | User <user> | 2013-07-29 15:33 | Install | 1
4 | User <user> | 2013-07-21 15:10 | Install | 1
3 | User <user> | 2013-07-16 15:27 | I, U | 73
2 | System <unset> | 2013-07-16 15:19 | Update | 1
1 | System <unset> | 2013-07-16 14:38 | Install | 1106
history listyum history list コマンドはすべての形式で、以下のコラムで構成される各行を含む表形式出力を生成します。
ID— 特定のトランザクションを識別する整数値です。Login user— ユーザー名で、この名前のログインセッションを使ってトランザクションが開始されました。この情報は、通常Full Name <username>の形式で表示されます。ユーザーが実行しなかったトランザクションに関しては (システムの自動更新など)、代わりにSystem <unset>が使用されます。Date and time— トランザクションが発生した日時です。Action(s)— 表9.1「Action フィールドの値」 の説明のとおり、トランザクション中に実行された動作の一覧です。Altered— 表9.2「Altered フィールドの値」 の説明のとおり、トランザクションにより影響を受けたパッケージ数、場合によっては追加情報も含まれます。
表9.1 Action フィールドの値
| Action | 省略形 | 詳細 |
|---|---|---|
Downgrade | D | 1 つ以上のパッケージが旧バージョンにダウングレードされました。 |
Erase | E | 1 つ以上のパッケージが削除されました。 |
Install | I | 1 つ以上の新しいパッケージがインストールされました。 |
Obsoleting | O | 1 つ以上のパッケージが廃止として記録されました。 |
Reinstall | R | 1 つ以上のパッケージが再インストールされました。 |
Update | U | 1 つ以上のパッケージが新しいバージョンに更新されました。 |
表9.2 Altered フィールドの値
| 記号 | 詳細 |
|---|---|
< | トランザクションが終了する前に、rpmdb データベースが yum 以外で変更されました。 |
> | トランザクションが終了した後に、rpmdb データベースが yum 以外で変更されました。 |
* | トランザクションは失敗して終了しました。 |
# | トランザクションは正常に終了しましたが、yum はゼロ以外の終了コードを返しました。 |
E | トランザクションは正常に終了しましたが、エラーまたは警告が表示されました。 |
P | トランザクションは正常に終了しましたが、rpmdb データベースに問題がすでに存在していました。 |
s | トランザクションは正常に終了しましたが、--skip-broken コマンドラインオプションが使用され、特定のパッケージが省略されました。 |
rpmdb または yumdb データベースのコンテンツを、現在使用されている rpmdb または yumdb データベースと同期させるには、以下を入力します。
yumhistorysync
yumhistorystats
例9.20 yum history stats の出力例
~]# yum history stats
Loaded plugins: langpacks, product-id, subscription-manager
File : //var/lib/yum/history/history-2012-08-15.sqlite
Size : 2,766,848
Transactions: 41
Begin time : Wed Aug 15 16:18:25 2012
End time : Wed Feb 27 14:52:30 2013
Counts :
NEVRAC : 2,204
NEVRA : 2,204
NA : 1,759
NEVR : 2,204
rpm DB : 2,204
yum DB : 2,204
history statsroot で以下の形式のコマンドを実行します。
yumhistorysummary
yumhistorysummarystart_id..end_id
yum history list コマンドと同様に、パッケージの名前または glob 表現を指定することで、特定のパッケージに関するトランザクションのサマリーを表示することできます。
yumhistorysummaryglob_expression…
例9.21 最新のトランザクション 5 件のサマリー
~]# yum history summary 1..5
Loaded plugins: langpacks, product-id, subscription-manager
Login user | Time | Action(s) | Altered
-------------------------------------------------------------------------------
Jaromir ... <jhradilek> | Last day | Install | 1
Jaromir ... <jhradilek> | Last week | Install | 1
Jaromir ... <jhradilek> | Last 2 weeks | I, U | 73
System <unset> | Last 2 weeks | I, U | 1107
history summaryyum history summary コマンドはすべての形式で、yum history list の出力に似た、簡略化された表形式出力を生成します。
yum history list および yum history summary とも、トランザクション向けに設定されています。特定のパッケージに関連するトランザクションのみを表示することができますが、パッケージバージョンのような重要な詳細は表示されません。パッケージに関連するトランザクションを一覧表示するには、root で以下のコマンドを実行します。
yumhistorypackage-listglob_expression…
例9.22 パッケージ履歴の追跡
~]# yum history package-list subscription-manager\*
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
ID | Action(s) | Package
-------------------------------------------------------------------------------
2 | Updated | subscription-manager-1.13.22-1.el7.x86_64 EE
2 | Update | 1.15.9-15.el7.x86_64 EE
2 | Obsoleted | subscription-manager-firstboot-1.13.22-1.el7.x86_64 EE
2 | Updated | subscription-manager-gui-1.13.22-1.el7.x86_64 EE
2 | Update | 1.15.9-15.el7.x86_64 EE
2 | Obsoleting | subscription-manager-initial-setup-addon-1.15.9-15.el7.x86_64 EE
1 | Install | subscription-manager-1.13.22-1.el7.x86_64
1 | Install | subscription-manager-firstboot-1.13.22-1.el7.x86_64
1 | Install | subscription-manager-gui-1.13.22-1.el7.x86_64
history package-list9.4.2. トランザクションの検証
root で以下の形式で yum history summary コマンドを使用します。
yumhistorysummaryid
root で以下のコマンドを実行します。
yumhistoryinfoid…
yumhistoryinfostart_id..end_id
例9.23 yum history info の出力例
~]# yum history info 4..5
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Transaction ID : 4..5
Begin time : Mon Dec 7 16:51:07 2015
Begin rpmdb : 1252:d2b62b7b5768e855723954852fd7e55f641fbad9
End time : 17:18:49 2015 (27 minutes)
End rpmdb : 1253:cf8449dc4c53fc0cbc0a4c48e496a6c50f3d43c5
User : Maxim Svistunov <msvistun>
Return-Code : Success
Command Line : install tigervnc-server.x86_64
Command Line : reinstall tigervnc-server
Transaction performed with:
Installed rpm-4.11.3-17.el7.x86_64 @rhel-7-server-rpms
Installed subscription-manager-1.15.9-15.el7.x86_64 @rhel-7-server-rpms
Installed yum-3.4.3-132.el7.noarch @rhel-7-server-rpms
Packages Altered:
Reinstall tigervnc-server-1.3.1-3.el7.x86_64 @rhel-7-server-rpms
history inforoot としてシェルプロンプトで以下を入力します。
yumhistoryaddon-infoid
yum history info と同様に、id が指定されていない場合は、yum は自動的に最新のトランザクションを使用します。別の方法として、最新のトランザクションを参照するには、last キーワードを使用することもできます。
yumhistoryaddon-infolast
例9.24 yum history addon-info の出力例
yum history addon-info は以下の出力を返します。
~]# yum history addon-info 4
Loaded plugins: langpacks, product-id, subscription-manager
Transaction ID: 4
Available additional history information:
config-main
config-repos
saved_tx
history addon-infoyum history addon-info コマンドの出力では、以下の 3 種類の情報が表示されます。
config-main— トランザクション時に使用された yum のグローバルオプションです。グローバルオプションの変更方法の詳細は、「[main] オプションの設定」 を参照してください。config-repos— 個々の yum リポジトリー用のオプションです。個々のリポジトリー用のオプションを変更する方法については、「[repository] オプションの設定」 を参照してください。saved_tx— 別のマシンでトランザクションを繰り返すためにyum load-transactionコマンドにより利用できるデータです (下記参照)。
root で以下のコマンドを実行してください。
yumhistoryaddon-infoid information
9.4.3. トランザクションを元に戻す/繰り返す
yum history コマンドは選択したトランザクションを元に戻す/繰り返す方法を提供します。トランザクションを元に戻すには、root としてシェルプロンプトで以下を入力します。
yumhistoryundoid
root で以下のコマンドを実行します。
yumhistoryredoid
last キーワードを使用して、最新のトランザクションを元に戻す、または繰り返すことができます。
yum history undo および yum history redo コマンドのどちらも、トランザクション中に実行されたステップを元に戻すまたは繰り返すだけである点に注意してください。トランザクションにより新しいパッケージがインストールされた場合、yum history undo コマンドはそれをアンインストールします。トランザクションによりパッケージがアンインストールされた場合、このコマンドは再度インストールします。またこのコマンドは、すべての更新済みパッケージを以前のバージョンにダウングレードする試みも実行します (古いパッケージが引き続き利用可能な場合)。
root でシェルプロンプトに以下を入力します。
yum-qhistoryaddon-infoidsaved_tx>file_name
root で以下のコマンドを使用してトランザクションを繰り返すことができます。
yumload-transactionfile_name
load-transaction を設定することも可能です。これらの設定オプションについての詳細は、yum.conf(5) の man ページを参照してください。
9.4.4. 新しいトランザクション履歴の開始
root で以下のコマンドを実行します。
yumhistorynew
/var/lib/yum/history/ ディレクトリー内に新しい空のデータベースファイルが作成されます。古いトランザクション履歴は保存されますが、新しいデータベースファイルがディレクトリーにある限りアクセスすることはできません。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.