RHEL 7 yumコマンドがエラーで使えない

9月 29, 2022AmazonLinux_CentOS,OperatingSystem

概要

  • EC2 上に起動したRHEL(Red Hat Enterprise Linux) 7 の環境において、yumコマンドを実行すると下記の様なエラーとなり、yumコマンドが使用できません。
  • 原因は、rh-amazon-rhui-client が 2.x 以下だとリポジトリにアクセスできないことが原因のようです。

$ yum list installed
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/product/rhui-client-config-server-7.crt
Repo rhui-REGION-client-config-server-7 forced skip_if_unavailable=True due to: /etc/pki/rhui/rhui-client-config-server-7.key
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/product/content-rhel7.crt
Repo rhui-REGION-rhel-server-releases forced skip_if_unavailable=True due to: /etc/pki/rhui/content-rhel7.key
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/cdn.redhat.com-chain.crt
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/product/content-rhel7.crt
Repo rhui-REGION-rhel-server-rh-common forced skip_if_unavailable=True due to: /etc/pki/rhui/content-rhel7.key
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast

Could not contact any CDS load balancers: rhui3.ap-northeast-1.aws.ce.redhat.com.

 

  • rpmコマンドで rh-amazon-rhui-client のバージョンを確認します。以下の様に、2.x 以下だと該当します。
$ rpm -qa rh-amazon-rhui-client
rh-amazon-rhui-client-2.2.117-1.el7.noarch
$ rpm -qa rh-amazon-rhui-client
rh-amazon-rhui-client-2.2.133-1.el7.noarch

 

対処方法

  • RHEL7.9 の AMI (例: ami-0155fdd0956a0c7a0) を使用して、新規にインスタンスを起動します。自力で、RHEL のAMIを探すのは労力が掛かります。
  • yumdownloader rh-amazon-rhui-client コマンドを使用して、rh-amazon-rhui-clientの最新RPM モジュールを取得します。念のため、rh-amazon-rhui-client のバージョンが 3.x 以降であることを確認します。

 

[ec2-user@ip-xx-xx-xx-xx ~]$ rpm -qa rh-amazon-rhui-client
rh-amazon-rhui-client-3.0.41-1.el7.noarch

[ec2-user@ip-xx-xx-xx-xx ~]$ sudo yumdownloader rh-amazon-rhui-client
Loaded plugins: amazon-id
rhel-7-server-rhui-rh-common-rpms                        | 3.8 kB     00:00     
rhel-7-server-rhui-rpms                                  | 3.5 kB     00:00     
rhui-client-config-server-7                              | 2.0 kB     00:00     
(8/8): rhel-7-server-rhui-rpms/7Server/x86_64/primary_db   |  90 MB   00:01     
rhui-client-config-server-7: [###################################         ] 4/5
rh-amazon-rhui-client-4.0.4-1.el7.noarch.rpm               |  34 kB   00:00     

[ec2-user@ip-xx-xx-xx-xx ~]$ ls
rh-amazon-rhui-client-4.0.4-1.el7.noarch.rpm

 

  • インストール対象のインスタンスに、scpコマンドやS3 経由でファイルを送ります。
  • rpm -U コマンドでrh-amazon-rhui-client を更新します。
$ sudo rpm -Uvh ./rh-amazon-rhui-client-4.0.4-1.el7.noarch.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:rh-amazon-rhui-client-4.0.4-1.el7warning: /etc/yum.repos.d/redhat-rhui-client-config.repo saved as /etc/yum.repos.d/redhat-rhui-client-config.repo.rpmsave
warning: /etc/yum.repos.d/redhat-rhui.repo saved as /etc/yum.repos.d/redhat-rhui.repo.rpmsave
################################# [ 50%]
[INFO:choose_repo] choose_repo:37 2022-09-29 08:48:26,042: Enabling binary repos in redhat-rhui.repo
[INFO:choose_repo] choose_repo:56 2022-09-29 08:48:26,042: Enabling client config repo
[INFO:choose_repo] choose_repo:66 2022-09-29 08:48:26,043: Executing [sed -i 's/enabled=0/enabled=1/' /etc/yum.repos.d/redhat-rhui-client-config.repo]
Cleaning up / removing...
   2:rh-amazon-rhui-client-2.2.133-1.ewarning: /etc/yum/pluginconf.d/rhui-lb.conf saved as /etc/yum/pluginconf.d/rhui-lb.conf.rpmsave
warning: /etc/yum.repos.d/rhui-load-balancers.conf saved as /etc/yum.repos.d/rhui-load-balancers.conf.rpmsave
################################# [100%]

$ rpm -qa rh-amazon-rhui-client
rh-amazon-rhui-client-4.0.4-1.el7.noarch
  • rh-amazon-rhui-client が4.0 に更新されました。これで目的のyum コマンドが実行できます。