EC2でyum updateしようとしたら以下のエラーが発生した。
前提として
・EC2はPrivate Subnetに配置してある
・VPCエンドポイントは設定済み
である。
[ec2-user@ip-10-0-77-0 ~]$ sudo yum update
読み込んだプラグイン: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, 'Resolving timed out after 5000 milliseconds')
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
Resolving timed out after 5000 milliseconds
でggったら公式リファレンスが引っかかった。
https://aws.amazon.com/jp/premiumsupport/knowledge-center/ec2-troubleshoot-yum-errors-al1-al2/
けど内容が正直よく分からない・・・(YourDNSって何?どう正しければ良いの?何を直せばいいの?)
「Resolving timed out after 5000 milliseconds」
次のコマンドを実行して、/etc/resolv.conf ファイルに DNS サーバーの正しい IP があることを確認します。
cat /etc/resolv.conf
nameserver YourDNSIP
取り急ぎの対応だとは思うが、とりあえずこの /etc/resolv.conf
の設定を変えることで自分の場合がyum使えるようになりました。
以下手順です。
①sudo権限で/etc/resolv.confを編集する
$ sudo vi /etc/resolv.conf
②nameserver {IPアドレス}の部分を上書きする。(上書きしたら!wqで保存。)
(変更前)
nameserver {IPアドレス}
(変更後)
nameserver 8.8.8.8
nameserver 8.8.4.4
これで出来ない場合は上に貼った公式リファレンスを上から眺めていくと良いかもです。