1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Linux ローカルリポジトリ構築(備忘録)

1
Posted at

Linux ローカルリポジトリ構築(備忘録)

概要

本ドキュメントは、Linux サーバ上にローカルリポジトリを作成し、他サーバから利用できるようにするまでの手順をまとめた備忘録。
RHEL 系 (yum / dnf) を想定。


1. 必要パッケージのインストール

ローカルリポジトリ作成に必要な createrepo をインストール。

sudo dnf install -y createrepo

2. リポジトリ用ディレクトリの作成

sudo mkdir -p /var/repos/base
sudo mkdir -p /var/repos/updates

3. パッケージの取得

指定パッケージを取得

sudo dnf download --resolve vim-enhanced

リポジトリ丸ごとミラー

sudo reposync -m --repo=rhel-9-baseos-rpms --download-path=/var/repos/base

必要に応じて yum-utils をインストール:

sudo dnf install -y yum-utils

4. リポジトリメタデータ作成

sudo createrepo /var/repos/base
sudo createrepo /var/repos/updates

更新時:

sudo createrepo --update /var/repos/base

5. Apache による公開

sudo dnf install -y httpd
sudo systemctl enable --now httpd
sudo ln -s /var/repos /var/www/html/repos

6. 各サーバ側の設定

/etc/yum.repos.d/local.repo を作成:

[local-base]
name=Local Base Repository
baseurl=http://<repo-server>/repos/base/
enabled=1
gpgcheck=0

[local-updates]
name=Local Updates Repository
baseurl=http://<repo-server>/repos/updates/
enabled=1
gpgcheck=0

7. 動作確認

sudo dnf clean all
sudo dnf makecache
sudo dnf repolist
sudo dnf install vim-enhanced
1
0
1

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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?