Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

8.4.5. yum リポジトリーの追加、有効化、および無効化

「[repository] オプションの設定」 Yum リポジトリーの定義に使用できる各種のオプションを説明しました。本セクションでは、yum-config-manager コマンドを使用してリポジトリーを追加、有効化、および無効化する方法を説明します。
/etc/yum.repos.d/redhat.repo ファイル
システムが証明書ベースの Red Hat Network に登録されると、Red Hat サブスクリプションマネージャーツールを使用して、/etc/yum.repos.d/redhat.repo ファイル内のリポジトリーを管理します。Red Hat Network にシステムを登録する方法や、Red Hat Subscription Manager ツールを使用してサブスクリプションを管理する方法は、6章システム登録およびサブスクリプション管理 を参照してください。

yum リポジトリーの追加

新しいリポジトリーを定義するには、[repository] セクションを /etc/yum.conf ファイル、または /etc/yum.repos.d/ ディレクトリーの .repo ファイルに追加します。このディレクトリーにある .repo ファイル拡張子が付いたすべてのファイルは、yum が読み取ります。リポジトリーは、/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 です( yum repolist all を使用して、利用可能なリポジトリー ID を一覧表示します)。別の方法では、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
[output truncated]
成功すると、yum-config-manager --enable コマンドは現在のリポジトリー設定を表示します。

yum リポジトリーの無効化

Yum リポジトリーを無効にするには、root で以下のコマンドを実行します。
yum-config-manager --disable repository
repository は一意のリポジトリー ID です( yum repolist all を使用して、利用可能なリポジトリー ID を一覧表示します)。yum-config-manager --enable と同様に、glob 表現を使用して、一致するすべてのリポジトリーを同時に無効にできます。
yum-config-manager --disable glob_expression
成功すると、yum-config-manager --disable コマンドは現在の設定を表示します。