LoginSignup
32
34

More than 5 years have passed since last update.

VirtualBoxのCentOS7で yum install したら Could not retrieve mirrorlist となった時の対応方法

Posted at

環境

  • ホストOS : macOS Sierra Virsion 10.12.5
  • VirtualBox : Version 5.1.22 r115126 (Qt5.6.2)
    • ゲストOS : CentOS Linux 7.3.1611(Core)
    • 接続 : ブリッジ接続
    • Yum version : 3.4.3

現象

$ sudo yum install bzip2
[sudo] password for mana: 
読み込んだプラグイン:fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 不明なエラー"


 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: base/7/x86_64

原因 : CentOSのネットワークにGATEWAYとDNSが設定されていないため、インターネットにつながっていないから

対応 : インターネットに繋がるように設定を見直す

  1. GATEWAYとDNSを設定する
  2. yum updateでYumが繋がることを確認する
$ sudo yum update
[sudo] password for mana: 
読み込んだプラグイン:fastestmirror
base                                                                                                                                   | 3.6 kB  00:00:00     
extras                                                                                                                                 | 3.4 kB  00:00:00     
updates                                                                                                                                | 3.4 kB  00:00:00     
(1/4): extras/7/x86_64/primary_db                                                                                                      | 190 kB  00:00:00     
(2/4): base/7/x86_64/group_gz                                                                                                          | 155 kB  00:00:01     
(3/4): base/7/x86_64/primary_db                                                                                                        | 5.6 MB  00:00:01     
(4/4): updates/7/x86_64/primary_db                                                                                                     | 7.7 MB  00:00:03     
Determining fastest mirrors
 * base: ftp.nara.wide.ad.jp
<省略>
$ yum --version
3.4.3
インストール: rpm-4.11.3-21.el7.x86_64 (日時: 2017-05-29 12:57)
  構築      : CentOS BuildSystem <http://bugs.centos.org>  (日時: 2016-11-05 23:37)
  コミット  : Florian Festi <ffesti@redhat.com> (日時: 2016-07-26)
<省略>

3. もう1度 yum install する

$ sudo yum install bzip2
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.tsukuba.wide.ad.jp
 * updates: ftp.tsukuba.wide.ad.jp
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> パッケージ bzip2.x86_64 0:1.0.6-13.el7 を インストール
--> 依存性解決を終了しました。

依存性を解決しました

==============================================================================================================================================================
 Package                             アーキテクチャー                     バージョン                                 リポジトリー                        容量
==============================================================================================================================================================
インストール中:
 bzip2                               x86_64                               1.0.6-13.el7                               base                                52 k

トランザクションの要約
==============================================================================================================================================================
インストール  1 パッケージ

総ダウンロード容量: 52 k
インストール容量: 82 k
Is this ok [y/d/N]: y
Downloading packages:
bzip2-1.0.6-13.el7.x86_64.rpm                                                                                                          |  52 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  インストール中          : bzip2-1.0.6-13.el7.x86_64                                                                                                     1/1 
  検証中                  : bzip2-1.0.6-13.el7.x86_64                                                                                                     1/1 

インストール:
  bzip2.x86_64 0:1.0.6-13.el7                                                                                                                                 

完了しました!
32
34
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
32
34