Show Table of Contents
6.3.5. Yum リポジトリを有効/設定/無効にする方法
「[repository] オプションの設定」 では、Yum リポジトリを定義するために使用できる様々なオプションについて説明しました。本項では、
yum-config-manager コマンドを使用してリポジトリを追加/有効/無効にする方法を説明します。
重要
システムが証明書ベースの
Red Hat Network に登録された場合、/etc/yum.repos.d/redhat.repo ファイル内のリポジトリを管理するには Red Hat サブスクリプションマネージャ ツールを使用します。Red Hat Network へのシステムの登録方法、サブスクリプションを管理するための Red Hat サブスクリプションマネージャ ツールの使用方法については、5章システム登録およびサブスクリプションの管理 を参照して下さい。
Yum リポジトリの追加
新しいリポジトリを定義するには、
[repository] セクションを /etc/yum.conf ファイルか、/etc/yum.repos.d/ ディレクトリ内の .repo ファイルに追加します。yum は、このディレクトリ内にある .repo ファイル拡張子が付いたすべてのファイルを読み取ることができます。/etc/yum.conf 内ではなくここにリポジトリを定義することを推奨します。
警告
Red Hat Network 以外の未検証または信頼できないソフトウェアソースからソフトウェアパッケージを取得してインストールする場合には、セキュリティ上のリスクが伴います。セキュリティ、安定性、互換性、保全性に関する問題が発生する恐れがあります。
通常 Yum リポジトリにはそれぞれの
.repo ファイルがあります。あるリポジトリをシステムに追加して、有効にするには、root で以下のコマンドを実行します:
yum-config-manager--add-reporepository_url
repository_url は
.repo ファイルへのリンクです。例えば、http://www.example.com/example.repo にあるリポジトリを追加するには、シェルプロンプトで以下を入力します:
~]# yum-config-manager --add-repo http://www.example.com/example.repo
Loaded plugins: product-id, refresh-packagekit, subscription-manager
adding repo from: http://www.example.com/example.repo
grabbing file http://www.example.com/example.repo to /etc/yum.repos.d/example.repo
example.repo | 413 B 00:00
repo saved to /etc/yum.repos.d/example.repoYum リポジトリの有効化
特定のリポジトリを有効にするには、シェルプロンプトで
root として以下を入力します:
yum-config-manager--enablerepository…
repository は一意のリポジトリ ID です (利用可能なリポジトリ ID を一覧表示するには
yum repolist all を使用)。別の方法として、glob 表現を使用すると、一致するすべてのリポジトリを有効にすることができます:
yum-config-manager--enableglob_expression…
例えば、
[example]、[example-debuginfo]、[example-source] セクション内で定義されたリポジトリを有効にするには、以下を入力します。
~]# yum-config-manager --enable example\*
Loaded plugins: product-id, refresh-packagekit, subscription-manager
============================== repo: example ==============================
[example]
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/6Server
baseurl = http://www.example.com/repo/6Server/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/6Server/example
[出力は省略されています]
成功すれば、
yum-config-manager --enable コマンドは現在のリポジトリ設定を表示します。
Yum リポジトリの無効化
Yum リポジトリを無効にするには、
root で以下のコマンドを実行して下さい:
yum-config-manager--disablerepository…
repository は一意のリポジトリ ID です (利用可能なリポジトリ ID を一覧表示するには
yum repolist all を使用)。yum-config-manager --enable と同様に、glob 表現を使用して、一致するすべてのリポジトリを同時に無効にすることができます:
yum-config-manager--disableglob_expression…
成功すれば、
yum-config-manager --disable コマンドは現在の設定を表示します。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.