How to Set Up a Local Repository Server on Red Hat Enterprise Linux for Offline Package Installation

This is a standard offline repo setup for Red Hat Enterprise Linux


๐Ÿงฑ PART 1: Setup Repo Server (VM1)


๐Ÿ”ง Step 1: Install required tools

sudo dnf install -y dnf-plugins-core createrepo

๐Ÿ“ Step 2: Create repo directory

sudo mkdir -p /repo
cd /repo

๐Ÿ“ฆ Step 3: Download packages + dependencies

๐Ÿ‘‰ Example (MongoDB):

sudo dnf download --resolve mongodb-enterprise-server mongodb-mongosh

๐Ÿ‘‰ You can add more packages anytime:

sudo dnf download --resolve <package-name>

๐Ÿ” Step 4: Verify RPMs

ls -lh /repo

๐Ÿ‘‰ Must show .rpm files โœ…


๐Ÿ—๏ธ Step 5: Create repository metadata

sudo createrepo /repo

๐ŸŒ Step 6: Start repo server

Quick method (for testing)

cd /repo
python3 -m http.server 8080

๐Ÿ‘‰ Repo URL:

http://<VM1-IP>:8080

๐Ÿ”ฅ (Production recommended) Use Apache

sudo dnf install -y httpd
sudo systemctl enable httpd
sudo systemctl start httpd

Copy repo:

sudo cp -r /repo /var/www/html/

๐Ÿ‘‰ URL becomes:

http://<VM1-IP>/repo

๐Ÿงฑ PART 2: Configure Client VMs (VM2 & VM3)


๐Ÿ”ง Step 7: Create repo config

sudo vi /etc/yum.repos.d/local.repo

Paste:

[local-repo]
name=Local Repo
baseurl=http://<VM1-IP>:8080
enabled=1
gpgcheck=0

๐Ÿ‘‰ If using Apache:

baseurl=http://<VM1-IP>/repo

๐Ÿ”„ Step 8: Refresh repo

sudo dnf clean all
sudo dnf makecache

๐Ÿ” Step 9: Verify packages

dnf list available | grep mongo

๐Ÿ‘‰ Packages should appear โœ…


๐Ÿงฑ PART 3: Install Packages from Repo


๐Ÿ“ฅ Step 10: Install

sudo dnf install -y mongodb-enterprise-server mongodb-mongosh

๐Ÿ”„ PART 4: Adding New Packages Later


On VM1:

cd /repo
sudo dnf download --resolve <new-package>
sudo createrepo --update /repo

On VM2:

sudo dnf clean all
sudo dnf makecache

๐Ÿง  Best Practices

โœ… Always use:

dnf download --resolve

โœ” ensures dependencies included


โœ… Keep repo updated:

createrepo --update /repo

โœ… Use Apache for stability

  • survives reboot
  • production ready

๐ŸŽฏ Final Architecture

VM1 (Repo Server)
   โ†“ HTTP
VM2 -------- VM3
 (install packages from VM1)

๐Ÿš€ You now have

  • Offline package management โœ…
  • Centralized repo server โœ…
  • No need for subscription on other VMs โœ…

๐Ÿ‘ If you want next level

I can help you:

  • ๐Ÿ”„ Sync full RHEL repo locally (mirror)
  • โš™๏ธ Automate with Ansible
  • ๐Ÿ” Secure repo with GPG keys

Just tell me ๐Ÿ‘

Leave a Reply

Your email address will not be published. Required fields are marked *