【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

公開日時:2020年08月09日 / 最終更新日時:2020年08月09日

Amazon Linux 2 で yum update コマンドを実行したら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示され、yum update に失敗した場合の対応手順について解説します。

 

 

 

Amazon Linux 2 で初っ端 yum update が失敗する

Amazon Linux 2 がリリースされたということで、早速 Amazon Linux 2 を使ってみようと EC2 インスタンスを起動し、まずは yum update で最新の状態にしておこうとすると初っ端からエラーになります。

 

[root@amazonlinux2 ~]# yum update 
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd 
Could not retrieve mirrorlist http://amazonlinux.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.list error was 
12: Timeout on http://amazonlinux.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.list: (28, 'Connection timed out after 5000 milliseconds') 
 
 
 One of the configured repositories failed (Unknown), 
 and yum doesn't have enough cached data to continue. At this point the only 
 safe thing yum can do is fail. There are a few ways to work "fix" this: 
 
     1. Contact the upstream for the repository and get them to fix the problem. 
 
     2. Reconfigure the baseurl/etc. for the repository, to point to a working 
        upstream. This is most often useful if you are using a newer 
        distribution release than is supported by the repository (and the 
        packages for the previous distribution release still work). 
 
     3. Run the command with the repository temporarily disabled 
            yum --disablerepo= ... 
 
     4. Disable the repository permanently, so yum won't use it by default. Yum 
        will then just ignore the repository until you permanently enable it 
        again or use --enablerepo for temporary usage: 
 
            yum-config-manager --disable  
        or 
            subscription-manager repos --disable= 
 
     5. Configure the failing repository to be skipped, if it is unavailable. 
        Note that yum will try to contact the repo. when it runs most commands, 
        so will have to try and fail each time (and thus. yum will be be much 
        slower). If it is a very temporary problem though, this is often a nice 
        compromise: 
 
            yum-config-manager --save --setopt=.skip_if_unavailable=true 
 
Cannot find a valid baseurl for repo: amzn2-core/2/x86_64 
[root@amazonlinux2 ~]# 

 

 

 

 

 

Cannot find a valid baseurl for repo: amzn2-core/2/x86_64 のエラーが表示される原因

このエラーの原因ですが、Amazon Linux 2 の yum リポジトリにアクセスが出来ない為にエラーとなっています。

Amazon Linux 2 の yum リポジトリは、S3 にあり、AWS の内部からしかアクセスが許可されていません。

その為、VPC のエンドポイントの設定をして、S3 にある yum リポジトリにアクセスできるようにしてないとエラーとなります。

 

■エラーメッセージ

「Could not retrieve mirrorlist http://amazonlinux.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.list」

日本語に翻訳すると、「ミラーリストのhttp://amazonlinux.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.listの名前解決が出来ない。」となります。

 

しかし、nslookup コマンドで実行すると、名前解決はできているようです。

■nslookupコマンドで確認

[root@amazonlinux2 ~]# nslookup amazonlinux.ap-northeast-1.amazonaws.com 
Server:         192.168.0.2 
Address:        192.168.0.2#53 
 
Non-authoritative answer: 
amazonlinux.ap-northeast-1.amazonaws.com        canonical name = s3.dualstack.ap-northeast-1.amazonaws.com. 
Name:   s3.dualstack.ap-northeast-1.amazonaws.com ← s3にあることが分かります。 
Address: 52.2.1.22 
Name:   s3.dualstack.ap-northeast-1.amazonaws.com 
Address: 2405:dba0:4061:110:34db:45b:: 
 
[root@amazonlinux2 ~]# 

 

 

 

 

 

VPC エンドポイントの設定をする

VPC エンドポイントの設定で、amazonlinux.ap-northeast-1.amazonaws.com にアクセスできるように設定します。

 

 

AWS 管理画面のメニューより「ネットワーキングとコンテンツ配信」「VPC」をクリックします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

左側ペインより「エンドポイント」をクリックします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

 

「エンドポイントの作成」ボタンをクリックします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

「エンドポイントの作成」画面で以下のように設定して下にスクロールします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

 

以下のように設定して下にスクロールします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

 

 

以下のように設定して「エンドポイントの作成」ボタンをクリックします。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

 

 

 

下図のようにエンドポイントが作成されていることを確認します。

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

【AWS】Amazon Linux 2でyum updateしたら「Cannot find a valid baseurl for repo: amzn2-core/2/x86_64」のエラーが表示された場合の対応手順

 

 

 

 

 

yum update コマンドの確認

エンドポイントを作成したら yum update コマンドを実行して動作確認をします。

 

■yum updateコマンド実行

[root@amazonlinux2 ~]# yum update 
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd 
amzn2-core                                             | 3.7 kB  00:00:00 
amzn2extra-docker                                      | 3.0 kB  00:00:00 
(1/5): amzn2-core/2/x86_64/updateinfo                  | 245 kB  00:00:00 
(2/5): amzn2-core/2/x86_64/group_gz                    | 2.5 kB  00:00:00 
(3/5): amzn2extra-docker/2/x86_64/updateinfo           |   69 B  00:00:00 
(4/5): amzn2extra-docker/2/x86_64/primary_db           |  68 kB  00:00:00 
(5/5): amzn2-core/2/x86_64/primary_db                  |  43 MB  00:00:01 
Resolving Dependencies 
--> Running transaction check 
---> Package amazon-linux-extras.noarch 0:1.6.11-1.amzn2 will be updated 
---> Package amazon-linux-extras.noarch 0:1.6.12-1.amzn2 will be an update 
---> Package amazon-linux-extras-yum-plugin.noarch 0:1.6.11-1.amzn2 will be updated 
---> Package amazon-linux-extras-yum-plugin.noarch 0:1.6.12-1.amzn2 will be an update 
---> Package ca-certificates.noarch 0:2019.2.32-76.amzn2.0.2 will be updated 
---> Package ca-certificates.noarch 0:2019.2.32-76.amzn2.0.3 will be an update 
---> Package python.x86_64 0:2.7.18-1.amzn2 will be updated 
---> Package python.x86_64 0:2.7.18-1.amzn2.0.1 will be an update 
---> Package python-devel.x86_64 0:2.7.18-1.amzn2 will be updated 
---> Package python-devel.x86_64 0:2.7.18-1.amzn2.0.1 will be an update 
---> Package python-libs.x86_64 0:2.7.18-1.amzn2 will be updated 
---> Package python-libs.x86_64 0:2.7.18-1.amzn2.0.1 will be an update 
---> Package python2-rsa.noarch 0:3.4.1-1.amzn2 will be updated 
---> Package python2-rsa.noarch 0:3.4.1-1.amzn2.0.1 will be an update 
---> Package tzdata.noarch 0:2019c-1.amzn2 will be updated 
---> Package tzdata.noarch 0:2020a-1.amzn2 will be an update 
--> Finished Dependency Resolution 
 
Dependencies Resolved 
 
============================================================================================ 
 Package                         Arch      Version                  Repository          Size 
============================================================================================ 
Updating: 
 amazon-linux-extras             noarch    1.6.12-1.amzn2           amzn2-core          36 k 
 amazon-linux-extras-yum-plugin  noarch    1.6.12-1.amzn2           amzn2-core          10 k 
 ca-certificates                 noarch    2019.2.32-76.amzn2.0.3   amzn2-core         391 k 
 python                          x86_64    2.7.18-1.amzn2.0.1       amzn2-core          92 k 
 python-devel                    x86_64    2.7.18-1.amzn2.0.1       amzn2-core         403 k 
 python-libs                     x86_64    2.7.18-1.amzn2.0.1       amzn2-core         7.5 M 
 python2-rsa                     noarch    3.4.1-1.amzn2.0.1        amzn2-core          68 k 
 tzdata                          noarch    2020a-1.amzn2            amzn2-core         479 k 
 
Transaction Summary 
============================================================================================ 
Upgrade  8 Packages 
 
Total download size: 9.0 M 
Is this ok [y/d/N]: y 
Downloading packages: 
Delta RPMs disabled because /usr/bin/applydeltarpm not installed. 
(1/8): amazon-linux-extras-yum-plugin-1.6.12-1.amzn2.noarch.rpm     |  10 kB  00:00:00 
(2/8): amazon-linux-extras-1.6.12-1.amzn2.noarch.rpm                |  36 kB  00:00:00 
(3/8): ca-certificates-2019.2.32-76.amzn2.0.3.noarch.rpm            | 391 kB  00:00:00 
(4/8): python-2.7.18-1.amzn2.0.1.x86_64.rpm                         |  92 kB  00:00:00 
(5/8): python-devel-2.7.18-1.amzn2.0.1.x86_64.rpm                   | 403 kB  00:00:00 
(6/8): python2-rsa-3.4.1-1.amzn2.0.1.noarch.rpm                     |  68 kB  00:00:00 
(7/8): tzdata-2020a-1.amzn2.noarch.rpm                              | 479 kB  00:00:00 
(8/8): python-libs-2.7.18-1.amzn2.0.1.x86_64.rpm                    | 7.5 MB  00:00:00 
--------------------------------------------------------------------------------------- 
Total                                                        19 MB/s | 9.0 MB  00:00:00 
Running transaction check 
Running transaction test 
Transaction test succeeded 
Running transaction 
  Updating   : python-libs-2.7.18-1.amzn2.0.1.x86_64                    1/16 
  Updating   : python-2.7.18-1.amzn2.0.1.x86_64                         2/16 
  Updating   : amazon-linux-extras-1.6.12-1.amzn2.noarch                3/16 
  Updating   : amazon-linux-extras-yum-plugin-1.6.12-1.amzn2.noarch     4/16 
  Updating   : python-devel-2.7.18-1.amzn2.0.1.x86_64                   5/16 
  Updating   : python2-rsa-3.4.1-1.amzn2.0.1.noarch                     6/16 
  Updating   : ca-certificates-2019.2.32-76.amzn2.0.3.noarch            7/16 
  Updating   : tzdata-2020a-1.amzn2.noarch                              8/16 
  Cleanup    : python-devel-2.7.18-1.amzn2.x86_64                       9/16 
  Cleanup    : amazon-linux-extras-yum-plugin-1.6.11-1.amzn2.noarch    10/16 
  Cleanup    : amazon-linux-extras-1.6.11-1.amzn2.noarch               11/16 
  Cleanup    : python2-rsa-3.4.1-1.amzn2.noarch                        12/16 
  Cleanup    : ca-certificates-2019.2.32-76.amzn2.0.2.noarch           13/16 
  Cleanup    : tzdata-2019c-1.amzn2.noarch                             14/16 
  Cleanup    : python-2.7.18-1.amzn2.x86_64                            15/16 
  Cleanup    : python-libs-2.7.18-1.amzn2.x86_64                       16/16 
  Verifying  : python-devel-2.7.18-1.amzn2.0.1.x86_64                   1/16 
  Verifying  : python-2.7.18-1.amzn2.0.1.x86_64                         2/16 
  Verifying  : tzdata-2020a-1.amzn2.noarch                              3/16 
  Verifying  : python2-rsa-3.4.1-1.amzn2.0.1.noarch                     4/16 
  Verifying  : python-libs-2.7.18-1.amzn2.0.1.x86_64                    5/16 
  Verifying  : amazon-linux-extras-1.6.12-1.amzn2.noarch                6/16 
  Verifying  : amazon-linux-extras-yum-plugin-1.6.12-1.amzn2.noarch     7/16 
  Verifying  : ca-certificates-2019.2.32-76.amzn2.0.3.noarch            8/16 
  Verifying  : amazon-linux-extras-1.6.11-1.amzn2.noarch                9/16 
  Verifying  : python-2.7.18-1.amzn2.x86_64                            10/16 
  Verifying  : python2-rsa-3.4.1-1.amzn2.noarch                        11/16 
  Verifying  : python-devel-2.7.18-1.amzn2.x86_64                      12/16 
  Verifying  : python-libs-2.7.18-1.amzn2.x86_64                       13/16 
  Verifying  : ca-certificates-2019.2.32-76.amzn2.0.2.noarch           14/16 
  Verifying  : amazon-linux-extras-yum-plugin-1.6.11-1.amzn2.noarch    15/16 
  Verifying  : tzdata-2019c-1.amzn2.noarch                             16/16 
 
Updated: 
  amazon-linux-extras.noarch 0:1.6.12-1.amzn2         amazon-linux-extras-yum-plugin.noarch 0:1.6.12-1.amzn2 
  ca-certificates.noarch 0:2019.2.32-76.amzn2.0.3     python.x86_64 0:2.7.18-1.amzn2.0.1 
  python-devel.x86_64 0:2.7.18-1.amzn2.0.1            python-libs.x86_64 0:2.7.18-1.amzn2.0.1 
  python2-rsa.noarch 0:3.4.1-1.amzn2.0.1              tzdata.noarch 0:2020a-1.amzn2 
 
Complete! 
[root@amazonlinux2 ~]# 

 

 

 

 

Posted by 100%レンタルサーバーを使いこなすサイト管理人

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

AlphaOmega Captcha Medica  –  What Do You See?
     
 

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください

Secured By miniOrange