12
15

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が機能しなくなったので、とりあえずyumコマンドが動くようにした時のメモ

Last updated at Posted at 2018-09-04

前置き

rm -rf /var/cache/yum/*が原因だと思うが
yumが機能しなくなったので、とりあえずyumコマンドが動くようにした時のメモ

(一部、設定が適切でない部分などがあるかもしれません)

環境

VirtualBox上にLinux(CentOS7)をインストールして利用。
VirtualBoxのネットワーク設定は「ブリッジ接続」

yum動かなくなった

エラー
[root@centos7 ~]$yum list
^Chttp://mirror.centos.org/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirror.centos.org; 不明なエラー"
他のミラーを試します。

 One of the configured repositories failed (CentOS-7 - Base),
 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=base ...

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

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

failure: repodata/repomd.xml from base: [Errno 256] No more mirrors to try.
http://mirror.centos.org/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirror.centos.org; 不明なエラー"
エラーメッセージ中のキーワード
Could not resolve host

yum動かない時の対処

DNSを設定

/etc/sysconfig/network-scripts/ifcfg-????
# ファイル名「ifcfg-????」は環境によって異なる

# DNSを設定
DNS1=8.8.8.8
DNS2=8.8.4.4
/etc/resolv.conf
# 追記
nameserver 8.8.8.8
nameserver 8.8.4.4
ネットワーク再起動
service network restart
/etc/yum.repos.d/CentOS-Base.repo
# 何箇所かあるので、全ての箇所で
# 「mirrorlist〜」部分をコメントアウトして
# 「baseurl〜」部分を有効化する

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
確認
yum list
yum update

updateがおっそい。。。

参考

CentOSでyumを使えない時の対処法+ネットワーク設定
yum Error: Cannot find a valid baseurl for repo: baseの対処法 – rilakkuma3xjapan's blog

12
15
3

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
12
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?