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-repo
repository_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.repo
Yum リポジトリの有効化
特定のリポジトリを有効にするには、シェルプロンプトで
root
として以下を入力します:
yum-config-manager
--enable
repository…
repository は一意のリポジトリ ID です (利用可能なリポジトリ ID を一覧表示するには
yum repolist all
を使用)。別の方法として、glob 表現を使用すると、一致するすべてのリポジトリを有効にすることができます:
yum-config-manager
--enable
glob_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
--disable
repository…
repository は一意のリポジトリ ID です (利用可能なリポジトリ ID を一覧表示するには
yum repolist all
を使用)。yum-config-manager --enable
と同様に、glob 表現を使用して、一致するすべてのリポジトリを同時に無効にすることができます:
yum-config-manager
--disable
glob_expression…
成功すれば、
yum-config-manager --disable
コマンドは現在の設定を表示します。