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?

Privateサブネットに配置したEC2(Amazon Linux2)からyum installできない

Last updated at Posted at 2024-12-23

はじめに

RDSへの接続確認のため、Privateサブネットに配置したEC2インスタンスにMySQLをインストールしようとしたらエラーでハマったので対応方法をまとめる。

事象

Privateサブネットに配置したEC2(Amazon Linux2)にMySQLをインストールしようとしたところ、下記のエラーが発生してインストールできない

sudo yum -y install mysql

Could not retrieve mirrorlist https://amazonlinux-2-repos-ap-northeast-1.s3.dualstack.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.list error was
12: Timeout on https://amazonlinux-2-repos-ap-northeast-1.s3.dualstack.ap-northeast-1.amazonaws.com/2/core/latest/x86_64/mirror.list: (28, 'Connection timeout after 5000 ms')


 One of the configured repositories failed (不明),
 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=<repoid> ...

     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 <repoid>
        or
            subscription-manager repos --disable=<repoid>

     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=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: amzn2-core/2/x86_64

原因

Amazon Linux2のyumリポジトリはS3上に存在しているが、そのリポジトリにアクセスできていない。

対応方法

s3へのVPCエンドポイントを作成後にyum installする。

  1. VPC > VPCエンドポイント > エンドポイントを作成を選択
  2. タイプは「AWSのサービス」を選択
  3. サービス名はcom.amazonaws.ap-northeast-1.s3、タイプがGateWayのものを選択
  4. ルートテーブルの設定はEC2インスタンスが含まれるサブネットのルートテーブルを選択

おわりに

VPCエンドポイントの存在を初めて知った。
GateWayタイプは無料だが、Interfaceタイプは有料らしい。
違いについても機会があれば調べてみたい。

参考

0
0
0

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?