Wednesday, June 05, 2024

RHEL8 - Create Local HTTP Yum/DNF Repository

 A. Yum Server

1.      Install package httpd, createrepo

2.      Mount iso image for rhel8, edb4rhel8

[root@yum-server conf.d]# df –h

/dev/loop1              13G   13G     0 100% /edb

/dev/loop2              14G   14G     0 100% /rhel8

3.      Copy all files from mount disks to repository

[root@yum-server ~]# cp -r /rhel8/* /source/www/html/repo

[root@yum-server ~]# cp -r /edb/* /source/www/html/repo/EDB

4.      Create Repository Metadata

[root@yum-server ~]# createrepo /source/www/html/repo/BaseOS

[root@yum-server ~]# createrepo /source/www/html/repo/AppStream

[root@yum-server ~]# createrepo /source/www/html/repo/EDB

 

[root@yum-server ~]# ls -l /source/www/html/repo

total 400

dr-xr-xr-x 4 root root   4096 Jun  5 09:14 AppStream

dr-xr-xr-x 4 root root   4096 Jun  5 09:13 BaseOS

drwxr-xr-x 4 root root 331776 Jun  5 09:24 EDB

dr-xr-xr-x 3 root root   4096 Jun  5 08:59 EFI

-r--r--r-- 1 root root   8154 Jun  5 09:05 EULA

-r--r--r-- 1 root root   1455 Jun  5 09:05 extra_files.json

-r--r--r-- 1 root root  18092 Jun  5 09:05 GPL

dr-xr-xr-x 3 root root   4096 Jun  5 09:05 images

dr-xr-xr-x 2 root root   4096 Jun  5 09:05 isolinux

-r--r--r-- 1 root root    104 Jun  5 09:05 media.repo

drwxr-xr-x 2 root root   4096 Jun  5 09:30 repodata

-r--r--r-- 1 root root   1669 Jun  5 09:05 RPM-GPG-KEY-redhat-beta

-r--r--r-- 1 root root   5135 Jun  5 09:05 RPM-GPG-KEY-redhat-release

-r--r--r-- 1 root root   1796 Jun  5 09:05 TRANS.TBL

5.      Configuring Local Repository

[root@yum-server ~]# ls -l /etc/yum.repos.d/

-rw-r--r-- 1 root root  504 Jun  5 09:23 rhel8.repo

-r--r--r-- 1 root root 5135 Jun  4 13:40 RPM-GPG-KEY-RHEL8 (copy from RPM-GPG-KEY-redhat-release and rename)

 

[root@yum-server ~]# vi /etc/yum.repos.d/rhel8.repo

[rhel8u10_baseos]

name=Local - Red Hat Enterprise Linux 8.10 - BaseOS

baseurl=file:///source/www/html/repo/BaseOS/

gpgkey=file:///etc/yum.repos.d/RPM-GPG-KEY-RHEL8

gpgcheck=1

enabled=1

 

[rhel8u10_appstream]

name=Local - Red Hat Enterprise Linux 8.10 - Appstream

baseurl=file:///source/www/html/repo/AppStream/

gpgkey=file:///etc/yum.repos.d/RPM-GPG-KEY-RHEL8

gpgcheck=1

enabled=1

 

[edb4rhel8]

name=Local - Enterprise Database for RHEL8/OL8

baseurl=file:///source/www/html/repo/EDB/

gpgcheck=0

enabled=1 

 

6.      Testing Local Repository

[root@yum-server ~]# dnf clean all

[root@yum-server ~]# dnf repolist -v

Repo-id            : edb4rhel8

Repo-name          : Local - Enterprise Database for RHEL8/OL8

Repo-revision      : 1717554297

Repo-updated       : Wed 05 Jun 2024 09:24:57 AM +07

Repo-pkgs          : 4,291

Repo-available-pkgs: 3,624

Repo-size          : 13 G

Repo-baseurl       : file:///source/www/html/repo/EDB/

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:16:38 AM +07)

Repo-filename      : /etc/yum.repos.d/rhel8.repo

 

Repo-id            : rhel8u10_appstream

Repo-name          : Local - Red Hat Enterprise Linux 8.10 - Appstream

Repo-revision      : 1717553667

Repo-updated       : Wed 05 Jun 2024 09:14:27 AM +07

Repo-pkgs          : 7,117

Repo-available-pkgs: 5,672

Repo-size          : 11 G

Repo-baseurl       : file:///source/www/html/repo/AppStream/

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:16:38 AM +07)

Repo-filename      : /etc/yum.repos.d/rhel8.repo

 

Repo-id            : rhel8u10_baseos

Repo-name          : Local - Red Hat Enterprise Linux 8.10 - BaseOS

Repo-revision      : 1717553581

Repo-updated       : Wed 05 Jun 2024 09:13:01 AM +07

Repo-pkgs          : 1,742

Repo-available-pkgs: 1,737

Repo-size          : 1.5 G

Repo-baseurl       : file:///source/www/html/repo/BaseOS/

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:16:38 AM +07)

Repo-filename      : /etc/yum.repos.d/rhel8.repo

Total packages: 13,150

7.      Configuring HTTPD

-        Start httpd

o   [root@yum-server ~]# systemctl start httpd.service

o   [root@yum-server ~]# systemctl enable httpd.service

-        Edit /etc/httpd/conf/httpd.conf

o   ServerName yum-server.taolaoxibup.com:80

o   Directory "/source/www/html/repo"

o   DocumentRoot "/source/www/html/repo"

-        Restart httpd

o   [root@yum-server ~]# systemctl restart httpd.service  

B. Client

1.      Setup Local Yum Repository

[root@xxx-app ~]# vi /etc/yum.repos.d/edb4rhel8.repo

[rhel8u10_baseos]

name=Local - Red Hat Enterprise Linux 8.10 - BaseOS

baseurl=http://yum-server.taolaoxibup.com/BaseOS

gpgcheck=0

enabled=1

 

[rhel8u10_appstream]

name=Local - Red Hat Enterprise Linux 8.10 - Appstream

baseurl=http://yum-server.taolaoxibup.com/AppStream/

gpgcheck=0

enabled=1

 

[edb4rhel8]

name=Local - Enterprise Database for RHEL8/OL8

baseurl=http://yum-server.taolaoxibup.com/EDB/

gpgcheck=0

enabled=1 

2.      Verify the configuration

[root@xxx-app ~]# dnf clean all

[root@xxx-app ~]# dnf repolist -v

Repo-id            : edb4rhel8

Repo-name          : Local - Enterprise Database for RHEL8/OL8

Repo-revision      : 1717554297

Repo-updated       : Wed 05 Jun 2024 09:24:57 AM +07

Repo-pkgs          : 4,291

Repo-available-pkgs: 3,624

Repo-size          : 13 G

Repo-baseurl       : http://yum-server.taolaoxibup.com/EDB/

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:02:35 AM +07)

Repo-filename      : /etc/yum.repos.d/edb4rhel8.repo

 

Repo-id            : rhel8u10_appstream

Repo-name          : Local - Red Hat Enterprise Linux 8.10 - Appstream

Repo-revision      : 1717553667

Repo-updated       : Wed 05 Jun 2024 09:14:27 AM +07

Repo-pkgs          : 7,117

Repo-available-pkgs: 5,606

Repo-size          : 11 G

Repo-baseurl       : http://yum-server.taolaoxibup.com/AppStream/

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:02:35 AM +07)

Repo-filename      : /etc/yum.repos.d/edb4rhel8.repo

 

Repo-id            : rhel8u10_baseos

Repo-name          : Local - Red Hat Enterprise Linux 8.10 - BaseOS

Repo-revision      : 1717553581

Repo-updated       : Wed 05 Jun 2024 09:13:01 AM +07

Repo-pkgs          : 1,742

Repo-available-pkgs: 1,737

Repo-size          : 1.5 G

Repo-baseurl       : http://yum-server.taolaoxibup.com/BaseOS

Repo-expire        : 172,800 second(s) (last: Wed 05 Jun 2024 10:02:35 AM +07)

Repo-filename      : /etc/yum.repos.d/edb4rhel8.repo

Total packages: 13,150

C. How to connect to Oracle Linux Yum Server

Red Hat Enterprise Linux 9

1. Import the Oracle Linux GPG key
[root@postgres-master ~]# wget https://yum.oracle.com/RPM-GPG-KEY-oracle-ol9 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
[root@postgres-master ~]# cd /etc/pki/rpm-gpg/
[root@postgres-master rpm-gpg]# gpg --quiet --keyid-format 0xlong --with-fingerprint RPM-GPG-KEY-oracle


2. Ceate a temporary yum repository configuration file // creating /etc/yum.repos.d/ol9-temp.repo with the following as the minimum required content:

[ol9_baseos_latest]
name=Oracle Linux 9 BaseOS Latest  ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

3. Install oraclelinux-release-el9:
[root@postgres-master ~]# dnf install oraclelinux-release-el9

4. Remove ol9-temp.repo and any other remaining repo files that may conflict with Oracle Linux yum server:
[root@postgres-master ~]# mv /etc/yum.repos.d/ol9-temp.repo /etc/yum.repos.d/ol9-temp.repo.disabled

5. Verify yum repository
[root@postgres-master ~]# ls -l /etc/yum.repos.d/
total 16
-rw-r--r--. 1 root root 2792 May  1 16:13 oracle-linux-ol9.repo
-rw-r--r--. 1 root root  358 Jun  6 11:01 redhat.repo
-rw-r--r--. 1 root root  407 May  1 16:13 uek-ol9.repo
-rw-r--r--. 1 root root  229 May  1 16:13 virt-ol9.repo

[root@postgres-master ~]# dnf clean all
[root@postgres-master ~]# dnf repolist 

Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered with an entitlement server. You can use "rhc" or "subscription-manager" to register.

repo id                                                                                     repo name
ol9_UEKR7                                                                             Oracle Linux 9 UEK Release 7 (x86_64)
ol9_appstream                                                                         Oracle Linux 9 Application Stream Packages (x86_64)
ol9_baseos_latest                                                                     Oracle Linux 9 BaseOS Latest (x86_64)