何の話かというと
Red Hat Networkに登録したRHELシステムであれば、
# yum update
とすれば、すべてのパッケージが自動的に最新にアップデートされます。あるいは、
# yum install hogehoge
とすれば、hogehogeの最新バージョンと依存パッケージがまとめてインストールされます。
しかしながら、場合によっては、特定のパッケージだけ特定のバージョンに上げたい、とか、いきなりインストールするのではなくて、まずはRPMファイルをダウンロードして、根掘り葉掘り調べてからインストールしたい、という場合もあります。
このような際に、yumを使わずに、Red HatのCustomer Portalから個別にRPMをダウンロードして対応している方も多いと思いますが、実は、yumでもそのようなきめ細かな対応は可能です。特に、EC2/Nifty Cloudなどで時間課金のRHELを使う場合、始めからyumリポジトリにアクセスできるように構成されているので便利です。
以下、EC2のRHELでの操作例を示します。
リポジトリの構成の確認
EC2上にRHELのリポジトリが用意されています。
# yum repolist Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity rhui-ap-northeast-1-client-config-server-6 | 2.6 kB 00:00 rhui-ap-northeast-1-client-config-server-6/primary_db | 3.1 kB 00:00 rhui-ap-northeast-1-rhel-server-releases | 3.7 kB 00:00 rhui-ap-northeast-1-rhel-server-releases/primary_db | 18 MB 00:00 rhui-ap-northeast-1-rhel-server-releases-optional | 3.5 kB 00:00 rhui-ap-northeast-1-rhel-server-releases-optional/primar | 2.2 MB 00:00 repo id repo name status rhui-ap-northeast-1-client-config-server-6 Red Hat Update Infrastr 1 rhui-ap-northeast-1-rhel-server-releases Red Hat Enterprise Linu 8,896 rhui-ap-northeast-1-rhel-server-releases-optional Red Hat Enterprise Linu 5,477 repolist: 14,374
利用可能な全てのバージョンを確認
リポジトリには、最新バージョンだけではなく、古いバージョンもちゃんと入っています。「--showduplicate」オプションで確認できます。
# yum --showduplicate list httpd Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity Available Packages httpd.x86_64 2.2.15-5.el6 rhui-ap-northeast-1-rhel-server-releases httpd.x86_64 2.2.15-9.el6 rhui-ap-northeast-1-rhel-server-releases httpd.x86_64 2.2.15-9.el6_1.2 rhui-ap-northeast-1-rhel-server-releases httpd.x86_64 2.2.15-9.el6_1.3 rhui-ap-northeast-1-rhel-server-releases httpd.x86_64 2.2.15-15.el6 rhui-ap-northeast-1-rhel-server-releases httpd.x86_64 2.2.15-15.el6_2.1 rhui-ap-northeast-1-rhel-server-releases
特定バージョンをインストール
バージョン指定でインストールが可能です。
# yum install httpd-2.2.15-9.el6_1.3
Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-9.el6_1.3 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-9.el6_1.3 for package: httpd-2.2.15-9.el6_1.3.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-9.el6_1.3.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-9.el6_1.3.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-9.el6_1.3.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-9.el6_1.3 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.2.15-9.el6_1.3 rhui-ap-northeast-1-rhel-server-releases 808 k
Installing for dependencies:
apr x86_64 1.3.9-5.el6_2 rhui-ap-northeast-1-rhel-server-releases 123 k
apr-util
x86_64 1.3.9-3.el6_0.1 rhui-ap-northeast-1-rhel-server-releases 87 k
apr-util-ldap
x86_64 1.3.9-3.el6_0.1 rhui-ap-northeast-1-rhel-server-releases 15 k
httpd-tools
x86_64 2.2.15-9.el6_1.3 rhui-ap-northeast-1-rhel-server-releases 69 k
Transaction Summary
================================================================================
Install 5 Package(s)
Total download size: 1.1 M
Installed size: 3.5 M
Is this ok [y/N]: バージョン指定のアップデートも可能です。
# yum update httpd-2.2.15-15.el6
Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-9.el6_1.3 will be updated
---> Package httpd.x86_64 0:2.2.15-15.el6 will be an update
--> Processing Dependency: httpd-tools = 2.2.15-15.el6 for package: httpd-2.2.15-15.el6.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.2.15-9.el6_1.3 will be updated
---> Package httpd-tools.x86_64 0:2.2.15-15.el6 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
httpd x86_64 2.2.15-15.el6 rhui-ap-northeast-1-rhel-server-releases 808 k
Updating for dependencies:
httpd-tools
x86_64 2.2.15-15.el6 rhui-ap-northeast-1-rhel-server-releases 70 k
Transaction Summary
================================================================================
Upgrade 2 Package(s)
Total download size: 878 k
Is this ok [y/N]: バージョン指定のダウングレードも可能です。
# yum downgrade httpd-2.2.15-5.el6
Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager
Updating certificate-based repositories.
Unable to read consumer identity
Setting up Downgrade Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-5.el6 will be a downgrade
--> Processing Dependency: httpd-tools = 2.2.15-5.el6 for package: httpd-2.2.15-5.el6.x86_64
---> Package httpd.x86_64 0:2.2.15-15.el6 will be erased
--> Finished Dependency Resolution
Error: Package: httpd-2.2.15-5.el6.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
Requires: httpd-tools = 2.2.15-5.el6
Installed: httpd-tools-2.2.15-15.el6.x86_64 (@rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-15.el6
Available: httpd-tools-2.2.15-5.el6.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-5.el6
Available: httpd-tools-2.2.15-9.el6.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-9.el6
Available: httpd-tools-2.2.15-9.el6_1.2.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-9.el6_1.2
Available: httpd-tools-2.2.15-9.el6_1.3.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-9.el6_1.3
Available: httpd-tools-2.2.15-15.el6_2.1.x86_64 (rhui-ap-northeast-1-rhel-server-releases)
httpd-tools = 2.2.15-15.el6_2.1
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigestおっと。。。この場合は、依存パッケージも同時にダウングレードする必要があるようです。
# yum downgrade httpd-2.2.15-5.el6 httpd-tools-2.2.15-5.el6 Loaded plugins: amazon-id, product-id, rhui-lb, security, subscription-manager Updating certificate-based repositories. Unable to read consumer identity Setting up Downgrade Process Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-5.el6 will be a downgrade ---> Package httpd.x86_64 0:2.2.15-15.el6 will be erased ---> Package httpd-tools.x86_64 0:2.2.15-5.el6 will be a downgrade ---> Package httpd-tools.x86_64 0:2.2.15-15.el6 will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================================================ Package Arch Version Repository Size ================================================================================================================ Downgrading: httpd x86_64 2.2.15-5.el6 rhui-ap-northeast-1-rhel-server-releases 811 k httpd-tools x86_64 2.2.15-5.el6 rhui-ap-northeast-1-rhel-server-releases 68 k Transaction Summary ================================================================================================================ Downgrade 2 Package(s) Total download size: 879 k Is this ok [y/N]:
特定バージョンのRPMをダウンロード
yumdownloaderでRPMをダウンロードすることができます。--resolveオプションを指定すると、インストール時に依存してインストールされるRPMも併せてダウンロードします。
# yumdownloader --resolve httpd-2.2.15-9.el6_1.3 Loaded plugins: amazon-id, product-id, rhui-lb --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-9.el6_1.3 will be installed --> Processing Dependency: httpd-tools = 2.2.15-9.el6_1.3 for package: httpd-2.2.15-9.el6_1.3.x86_64 --> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-9.el6_1.3.x86_64 --> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-9.el6_1.3.x86_64 --> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-9.el6_1.3.x86_64 --> Running transaction check ---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed ---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed ---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed ---> Package httpd-tools.x86_64 0:2.2.15-9.el6_1.3 will be installed --> Finished Dependency Resolution httpd-2.2.15-9.el6_1.3.x86_64.rpm | 808 kB 00:00 httpd-tools-2.2.15-9.el6_1.3.x86_64.rpm | 69 kB 00:00 apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm | 15 kB 00:00 apr-util-1.3.9-3.el6_0.1.x86_64.rpm | 87 kB 00:00 apr-1.3.9-5.el6_2.x86_64.rpm | 123 kB 00:00 # ls apr-1.3.9-5.el6_2.x86_64.rpm apr-util-1.3.9-3.el6_0.1.x86_64.rpm apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm httpd-2.2.15-9.el6_1.3.x86_64.rpm httpd-tools-2.2.15-9.el6_1.3.x86_64.rpm
まとめて全部ダウンロード
reposyncコマンドを使うと、リポジトリをまるごとダウンロードすることも可能です。詳細はmanページで確認ください。