外部接続できるサーバでRHELの公式リポジトリをミラーして、内部リポジトリとして公開したい時
サブスクリプション関係はコチラ
サブスクリプションが割り当てられたRHELマシン(ここでは9.6)であれば、デフォルトで/etc/yum.repos.d配下にredhat.repoがあり、その中に公式リポジトリのエントリがあり、その他個別の.repoも配置される。
たとえば
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rhel/9/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
[zabbix-sources]
name=Zabbix Official Repository (source code) - $basearch
baseurl=https://repo.zabbix.com/zabbix/7.0/rhel/9/SRPMS
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-B5333005
gpgcheck=1
や、
[epel]
name=Extra Packages for Enterprise Linux 9 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/9/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-9&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
[epel-source]
name=Extra Packages for Enterprise Linux 9 - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/9/Everything/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-9&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-9
gpgcheck=1
など。
有効済みリポジトリの一覧を確認
[root@host01 ~]# dnf repolist
警告: Signature not supported. Hash algorithm SHA1 not available.
サブスクリプション管理リポジトリーを更新しています。
このシステムは、エンタイトルメントーバーに登録されていますが、更新は受信していません。subscription-manager でサブスクリプションを割り当てることができます。
repo id repo の名前
epel Extra Packages for Enterprise Linux 9 - x86_64
rhel-9-for-x86_64-appstream-rpms Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)
rhel-9-for-x86_64-baseos-rpms Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)
zabbix Zabbix Official Repository - x86_64
有効化可能なリポジトリを一覧化
[root@host01 ~]# subscription-manager repos --list
警告: Signature not supported. Hash algorithm SHA1 not available.
警告: Signature not supported. Hash algorithm SHA1 not available.
+----------------------------------------------------------+
/etc/yum.repos.d/redhat.repo で利用可能なリポジトリー
+----------------------------------------------------------+
リポジトリー ID: cnv-4.14-for-rhel-9-x86_64-rpms
リポジトリー名: Red Hat Container Native Virtualization 4.14 for RHEL 9 x86_64 (RPMs)
リポジトリー URL: https://cdn.redhat.com/content/dist/layered/rhel9/x86_64/cnv/4.14/os
有効: 0
リポジトリー ID: satellite-utils-6.18-for-rhel-9-x86_64-rpms
リポジトリー名: Red Hat Satellite Utils 6.18 for RHEL 9 x86_64 (RPMs)
リポジトリー URL: https://cdn.redhat.com/content/dist/layered/rhel9/x86_64/sat-utils/6.18/os
有効: 0
リポジトリー ID: cnv-4.15-for-rhel-9-x86_64-source-rpms
リポジトリー名: Red Hat Container Native Virtualization 4.15 for RHEL 9 x86_64 (Source RPMs)
リポジトリー URL: https://cdn.redhat.com/content/dist/layered/rhel9/x86_64/cnv/4.15/source/SRPMS
有効: 0
リポジトリー ID: rhocp-4.12-for-rhel-9-x86_64-debug-rpms
リポジトリー名: Red Hat OpenShift Container Platform 4.12 for RHEL 9 x86_64 (Debug RPMs)
リポジトリー URL: https://cdn.redhat.com/content/dist/layered/rhel9/x86_64/rhocp/4.12/debug
有効: 0
...(大量にある)
リポジトリを有効化する
設定後、repolistに追加されている
[root@host01 ~]# subscription-manager repos --enable rhocp-4.12-for-rhel-9-x86_64-debug-rpms
リポジトリー 'rhocp-4.12-for-rhel-9-x86_64-debug-rpms' は、このシステムに対して有効になりました。
警告: Signature not supported. Hash algorithm SHA1 not available.
警告: Signature not supported. Hash algorithm SHA1 not available.
[root@host01 ~]#
[root@host01 ~]# dnf repolist
警告: Signature not supported. Hash algorithm SHA1 not available.
サブスクリプション管理リポジトリーを更新しています。
このシステムは、エンタイトルメントーバーに登録されていますが、更新は受信していません。subscription-manager でサブスクリプションを割り当てることができます。
repo id repo の名前
epel Extra Packages for Enterprise Linux 9 - x86_64
rhel-9-for-x86_64-appstream-rpms Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)
rhel-9-for-x86_64-baseos-rpms Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)
rhocp-4.12-for-rhel-9-x86_64-debug-rpms Red Hat OpenShift Container Platform 4.12 for RHEL 9 x86_64 (Debug RPMs)
zabbix Zabbix Official Repository - x86_64
[root@host01 ~]#
有効化されると、/etc/yum.repos.d/redhat.repoの該当リポジトリも enabled = 1 になっていることが確認できる。
※
/etc/yum.repos.d/redhat.repo は subscription-manager によって自動生成されるため、
直接編集は非推奨。設定は subscription-manager コマンド経由で行う。
自前の.repoの場合は、ファイルの中身を直接enabled = 1にかえれば一覧に出てくるようになる。
必要なパッケージのインストール
yum-utilsとhttpdをインストールする
# dnf install dnf-plugins-core httpd
reposync実施
baseosとappstreamのリポジトリを内部に提供したい場合
リポジトリ毎にディレクトリを作成してsyncさせる
# mkdir -pv /localrpm/rhel9-baseos
# reposync --repoid=rhel-9-for-x86_64-baseos-rpms --download-path=/localrpm/rhel9-baseos --download-metadata
# mkdir -pv /localrpm/rhel9-appstream
# reposync --repoid=rhel-9-for-x86_64-appstream-rpms --download-path=/localrpm/rhel9-appstream --download-metadata
それぞれのディレクトリにrepodataとPackagesというディレクトリが作成され、その中にパッケージが格納される
[root@host01 localrpm]# ls
rhel9-appstream rhel9-baseos
[root@host01 localrpm]#
[root@host01 localrpm]# cd rhel9-baseos
[root@host01 rhel9-baseos]# ls
rhel-9-for-x86_64-baseos-rpms
[root@host01 rhel9-baseos]#
[root@host01 rhel9-baseos]# cd rhel-9-for-x86_64-baseos-rpms/
[root@host01 rhel-9-for-x86_64-baseos-rpms]# ls
Packages repodata
httpdセットアップ
格納されたパッケージをhttpで公開する
Alias /localrpm/ "/localrpm/"
<Directory "/localrpm/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
SELinuxを無効化にしていない場合、以下の対応も必要
# chcon -R -t httpd_sys_content_t /localrpm
または
# semanage fcontext -a -t httpd_sys_content_t "/localrpm(/.*)?"
# restorecon -R /localrpm
クライアント側の設定
内部リポジトリを参照するためのrepoファイルを作成する
[local-baseos]
name=Local RHOSO BaseOS Repository
baseurl=http://<リポジトリサーバのIP>/localrpm/rhel9-baseos/rhel-9-for-x86_64-baseos-rpms/
enabled=1
gpgcheck=0
baseurl は実際に repodata/ ディレクトリがある場所を指定
あとは
# dnf repolist
でリポジトリが表示されればOK
おまけ
パッケージのSHA256ハッシュ値を確認する
[root@host01 localrpm]# find |grep modulemd-tools-0.9.3
./rhel-9-for-x86_64-appstream-eus-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
./rhel-9-for-x86_64-appstream-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
[root@host01 localrpm]#
[root@host01 localrpm]# for i in `find |grep modulemd-tools-0.9-3`; do sha256sum $i; done
ed883b2eb90be46649a5ca27b8a5663c3a00c193ad4b6c1eca22c4a05f0c5ce5 ./rhel-9-for-x86_64-appstream-eus-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
ed883b2eb90be46649a5ca27b8a5663c3a00c193ad4b6c1eca22c4a05f0c5ce5 ./rhel-9-for-x86_64-appstream-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
[root@host01 localrpm]#
パッケージの署名を確認する
[root@host01 localrpm]# find |grep modulemd-tools-0.9.3
./rhel-9-for-x86_64-appstream-eus-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
./rhel-9-for-x86_64-appstream-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm
[root@host01 localrpm]#
[root@host01 localrpm]# for i in `find |grep modulemd-tools-0.9-3`; do rpm -K $i; done
警告: Signature not supported. Hash algorithm SHA1 not available.
./rhel-9-for-x86_64-appstream-eus-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm: digests signatures OK
警告: Signature not supported. Hash algorithm SHA1 not available.
./rhel-9-for-x86_64-appstream-rpms/Packages/m/modulemd-tools-0.9-3.el9.noarch.rpm: digests signatures OK
[root@host01 localrpm]#
インストール後に何らかの変更が加えられたファイルの一覧を表示する
インストール済みのパッケージとRPMファイルの情報を比較し、検証する
# rpm -qV modulemd-tools-0.9-3
何も出てこなければ変更は加えられていない、といえる
参考
というかここのほうが詳しい()