0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

yum -y updateしたらError: Cannot retrieve repository metadata (repomd.xml) for repository:となった時の対応方法

Last updated at Posted at 2019-05-20
  • 環境
    • AWS上に作ったインスタンス : Red Hat Enterprise Linux Server release 5.11
    • OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

事象 : yum -y updateしたら怒られた

$ sudo yum -y update
Loaded plugins: amazon-id, fastestmirror, rhui-lb, security
Loading mirror speeds from cached hostfile
 * rhui-REGION-client-config-server-5: rhui2-cds01.ap-northeast-1.aws.ce.redhat.com
 * rhui-REGION-rhel-server: rhui2-cds01.ap-northeast-1.aws.ce.redhat.com
https://rhui2-cds01.ap-northeast-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml: [Errno 14] HTTP Error 401: Auth orization Required
Trying other mirror.
https://rhui2-cds02.ap-northeast-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml: [Errno 14] HTTP Error 401: Authorization Required
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: rhui-REGION-client-config-server-5. Please verify its path and try again

原因1 : リポジトリが有効になっているから?

対応 : 不要なリポジトリであれば無効にする

# 1. メッセージから対象っぽい.repoファイルを開く
$ vi /etc/yum.repo.d/redhat-rhui-client-config.repo

# 2. ファイル末尾に以下を追記して保存する
enabled=0

# 3. もう一度トライするとできる
$ sudo yum -y update
Loaded plugins: amazon-id, fastestmirror, rhui-lb, security
Loading mirror speeds from cached hostfile
 * rhui-REGION-rhel-server: rhui2-cds01.ap-northeast-1.aws.ce.redhat.com
rhui-REGION-rhel-server                                                                                                                                                                                               | 3.4 kB     00:00
rhui-REGION-rhel-server/primary_db                                                                                                                                                                                    |  12 MB     00:00
Excluding Packages from Red Hat Enterprise Linux Server 5 (RPMs)
Finished
Skipping security plugin, no data
Setting up Update Process
Resolving Dependencies
Skipping security plugin, no data
--> Running transaction check
---> Package at.x86_64 0:3.1.8-84.el5_11.1 set to be updated
...........省略

暫定原因2 : 請求コードの情報(billingProducts)が抜けているから?

  • RHELインスタンスだとyumが使えない? - Qiita
  • 原因の切り分け
    • スナップショットからAMIを作成し、そのAMIからインスタンスを作成した場合にbillingProductsが抜けてしまう。
    • curl http://169.254.169.254/latest/dynamic/instance-identity/documentbillingProductsnull 担っている場合はこれが原因。
# billingProductsは設定されているので今回の原因ではない
$ curl http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "accountId" : "xxxxxxxxxxxxxxxxxxx",
  "availabilityZone" : "ap-northeast-1a",
  "kernelId" : "aki-176bf516",
  "ramdiskId" : null,
  "pendingTime" : "2019-05-21T00:19:02Z",
  "architecture" : "x86_64",
  "privateIp" : "xx.0.x.xx",
  "version" : "2017-09-30",
  "devpayProductCodes" : null,
  "marketplaceProductCodes" : null,
  "imageId" : "ami-0xxxxxxxxxxx",
  "billingProducts" : [ "bp-xxxxx" ],
  "instanceId" : "i-xxxxxxxxxxxxxxx",
  "instanceType" : "m2.4xlarge",
  "region" : "ap-northeast-1"
}

暫定原因3 : 名前解決できていないから?

# 名前解決できていないわけではないらしい
$ curl https://rhui2-cds01.ap-northeast-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
...省略

暫定対応 : hostsにリポジトリサーバを定義する

今回は違うけどもしこれが原因だったら・・・

  1. xxx.repo ファイル内のURLからIPアドレスを調べる
  2. AWSのRHLEの場合:URLのREGIONとなっているところをリージョン名的なものに置き換える
  3. ドメイン/IPアドレス サーチ 【whois情報検索】でIPアドレスを調べる
  4. /etc/hosts に書く

暫定原因4 : サーバの証明書が古いから?

これが原因っぽいが・・・うまく解決できない・・・

$ curl https://rhui2-cds01.ap-northeast-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). The default
 bundle is named curl-ca-bundle.crt; you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.

$ curl -k https://rhui2-cds01.ap-northeast-1.aws.ce.redhat.com/pulp/repos//rhui-client-config/rhel/server/5/x86_64/os/repodata/repomd.xml
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Authorization Required</title>
</head><body>
<h1>Authorization Required</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr>
<address>Apache/2.2.15 (Red Hat) Server at rhui2-cds01.ap-northeast-1.aws.ce.redhat.com Port 443</address>
</body></html>

試行錯誤

RHEL系の場合は /etc/pki/tls/certs/ca-bundle.crt はopensslパッケージに含まれているので、手動でごちゃごちゃ頑張らなくても、yum update openssl をすればca-bundle.crtも更新されるはず。
サーバのSSL CA(認証局)証明書が古くてcurl がエラーになる件 - うまいぼうぶろぐ

  1. OpenSSLを新しくすればいいと思った。
  2. yumでupdateはできないので、OpenSSL をソースからビルドする - Qiitaを参考にtarファイルをWinSCPでサーバに持ち込んでビルドしようと思った。
  3. $ yum -y remove openssl を実行したところcatviコマンドまでなくなった
  4. そしてインスタンス自体が /bin/sh: ro: No such file or directory Kernel panic - not syncing: Attempted to kill init! で起動しなくなった・・・・さよならインスタンス
0
0
2

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?