LoginSignup
11
17

More than 5 years have passed since last update.

Yum のリポジトリについて色々試す

Posted at

Yum のリポジトリについて色々試す

メモです。

参考

以下配下のドキュメントがとても充実していたので基本的にこちらを見れば問題なさそう。

6.3. Yum と Yum リポジトリの設定

環境

RHEL 7.5 で確認。

$cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.5 (Maipo)

Yum って何だっけ?

第6章 Yum

Yum は Red Hat パッケージマネージャーです。Yum は、パッケージ情報に関するクエリ、リポジトリからのパッケージのフェッチ、パッケージのインストールとアンインストール、さらには利用可能な最新バージョンへのシステム全体の更新を行うことができます。Yum は、更新/インストール/削除を実行しているパッケージで依存関係の自動解決を行います。そのため、利用可能なすべての依存パッケージを自動的に決定/フェッチ/インストールすることができます。

Yum は、新しい追加のリポジトリまたは パッケージソース を使って設定することができ、機能を向上して拡張する多くのプラグインも提供します。また、Yum は RPM が実行できる多くの同じタスクを行うことができます。さらに、多くのコマンドラインオプションも似ています。Yum を使うことで、1 つのマシンまたはマシンのグループ上でのパッケージ管理を簡単かつシンプルに行うことができます。

リポジトリを追加することも出来る、と。

設定されいてるリポジトリを見る

yum repolist allコマンドで確認できる。
なお、状態列が 無効 のものはそのとおりでリポジトリとしては登録されているものの使えない。

$sudo yum repolist all
読み込んだプラグイン:amazon-id, rhui-lb, search-disabled-repos
リポジトリー ID                                             リポジ  状態
rhui-REGION-client-config-server-7/x86_64                   Red Hat 有効:      0
rhui-REGION-rhel-server-debug-extras/7Server/x86_64         Red Hat 無効
rhui-REGION-rhel-server-debug-optional/7Server/x86_64       Red Hat 無効
rhui-REGION-rhel-server-debug-rh-common/7Server/x86_64      Red Hat 無効
rhui-REGION-rhel-server-debug-rhscl/7Server/x86_64          Red Hat 無効
rhui-REGION-rhel-server-debug-supplementary/7Server/x86_64  Red Hat 無効
rhui-REGION-rhel-server-extras/7Server/x86_64               Red Hat 無効
rhui-REGION-rhel-server-optional/7Server/x86_64             Red Hat 無効
rhui-REGION-rhel-server-releases/7Server/x86_64             Red Hat 有効: 20,501
rhui-REGION-rhel-server-releases-debug/7Server/x86_64       Red Hat 無効
rhui-REGION-rhel-server-releases-source/7Server/x86_64      Red Hat 無効
rhui-REGION-rhel-server-rh-common/7Server/x86_64            Red Hat 有効:    232
rhui-REGION-rhel-server-rhscl/7Server/x86_64                Red Hat 無効
rhui-REGION-rhel-server-source-extras/7Server/x86_64        Red Hat 無効
rhui-REGION-rhel-server-source-optional/7Server/x86_64      Red Hat 無効
rhui-REGION-rhel-server-source-rh-common/7Server/x86_64     Red Hat 無効
rhui-REGION-rhel-server-source-rhscl/7Server/x86_64         Red Hat 無効
rhui-REGION-rhel-server-source-supplementary/7Server/x86_64 Red Hat 無効
rhui-REGION-rhel-server-supplementary/7Server/x86_64        Red Hat 無効
repolist: 20,733

ここで yum の設定ファイルを見てみる。

$ cat /etc/yum.conf
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3

#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

様々なオプションが設定されている。
例えば cachedirはキャッシュとデータベースファイルを格納するディレクトリへの絶対パスである。
また、debugdelvelogfileなどの記載もあり、デバッグ時に使えそう。

以下のドキュメントにも記載があるように、reposdir=directoryと書くことでリポジトリ情報(.repo)の存在するディレクトリを指定できるが、今回は指定されていないのでデフォルトの/etc/yum.repos.d/を利用する。

6.3. Yum と Yum リポジトリの設定

# 3つのファイルが存在する。.repo は2つ
$ls /etc/yum.repos.d/
redhat-rhui-client-config.repo  redhat-rhui.repo  rhui-load-balancers.conf

# []内の文字列が一意のリポジトリIDで先程の repo list でも表示された
$cat /etc/yum.repos.d/redhat-rhui-client-config.repo
# The amazon ec2 region is now dynamically set via yum.  REGION can be replaced by the amazon ec2 region for debugging
[rhui-REGION-client-config-server-7]
name=Red Hat Update Infrastructure 2.0 Client Configuration Server 7
mirrorlist=https://rhui2-cds01.REGION.aws.ce.redhat.com/pulp/mirror/rhui-client-config/rhel/server/7/$basearch/os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
sslverify=1
sslcacert=/etc/pki/rhui/cdn.redhat.com-chain.crt
sslclientcert=/etc/pki/rhui/product/rhui-client-config-server-7.crt
sslclientkey=/etc/pki/rhui/rhui-client-config-server-7.key

# 上記と同じ形式で複数書いてある
$cat /etc/yum.repos.d/redhat-rhui.repo

# 何かの設定ファイル?
$cat /etc/yum.repos.d/rhui-load-balancers.conf
rhui2-cds01.ap-northeast-1.aws.ce.redhat.com
rhui2-cds02.ap-northeast-1.aws.ce.redhat.com

.repoファイルの書式は以下に記載あり。

6.3.2. [repository] オプションの設定

リポジトリの有効無効を変えてみる

6.3.5. Yum リポジトリを有効/設定/無効にする方法

enabledで有効無効を変えることが出来るので、試してみる。

# enabled を 1 から 0にする
$sudo vi /etc/yum.repos.d/redhat-rhui-client-config.repo

# 先程の結果と比べると先頭の「rhui-REGION-client-config-server-7」が無効になっているのが分かる
$sudo yum repolist all |grep rhui-REGION-client-config-server-7
rhui-REGION-client-config-server-7/x86_64                   Red Hat 無効

また、コマンドでも有効・無効が変えれるのでやってみる。

# yum-config-manager コマンドで有効化
$sudo  yum-config-manager --enable rhui-REGION-client-config-server-7

# 有効になった
$sudo yum repolist all |grep rhui-REGION-client-config-server-7
rhui-REGION-client-config-server-7/x86_64                   Red Hat 有効:      0

# enabled も 0から1に戻っている
$cat /etc/yum.repos.d/redhat-rhui-client-config.repo  |grep enabled
enabled=1

OK.

リポジトリ(epel)を追加してみる

RHEL にないパッケージをインストールするために他のリポジトリを追加してみる。
RHEL7.5も以下の方法で出来そうなのでこちらでやってみる。

EPEL repository on rhel 7.4

# rpm をインストール
$sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# epel のリポジトリが追加されている
$ls /etc/yum.repos.d/
epel-testing.repo  redhat-rhui-client-config.repo  rhui-load-balancers.conf
epel.repo          redhat-rhui.repo

# epel/x86_64 リポジトリが有効になっている。リポジトリは Extra となっており、外部のものであることが分かる。
$sudo yum repolist
読み込んだプラグイン:amazon-id, rhui-lb, search-disabled-repos
リポジトリー ID                                  リポジトリー名           状態
epel/x86_64                                      Extra Packages for Enter 12,584
rhui-REGION-client-config-server-7/x86_64        Red Hat Update Infrastru      0
rhui-REGION-rhel-server-releases/7Server/x86_64  Red Hat Enterprise Linux 20,501
rhui-REGION-rhel-server-rh-common/7Server/x86_64 Red Hat Enterprise Linux    232
repolist: 33,317

# epel のパッケージのリストを表示
$sudo yum  list available |grep epel

# zabbix をインストールしてみる。epel リポジトリを利用している
$sudo yum install zabbix
・・・
================================================================================
 Package           アーキテクチャー
                                   バージョン               リポジトリー   容量
================================================================================
インストール中:
 zabbix22          x86_64          2.2.21-1.el7             epel          225 k

トランザクションの要約

インストール:
  zabbix22.x86_64 0:2.2.21-1.el7

完了しました!


以下のようなドキュメントもあった。

CentOS、RHEL、または Amazon Linux が実行されている Amazon EC2 インスタンスに対して EPEL リポジトリを有効にする方法を教えてください。

11
17
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
11
17