8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Linux » Here

Create a Local Yum Repository for Oracle Linux 8

This article describes the process of setting up local Yum repositories for Oracle Linux using yum.oracle.com as the source repository. If you have a ULN subscription, you should use the method described here.

Thanks to Todd Vierling for the heads up about a bunch of changes regarding RHEL8/OL8.

Repository Creation

Install the following packages, which include the utilities necessary to set up the repository.

# dnf install -y dnf-utils

Create the following directories to hold the main OS and UEK respoitories.

# mkdir -p /u01/repo/OracleLinux
# mkdir -p /u01/repo/logs
# mkdir -p /u01/repo/scripts

If you've done a default installation of Oracle Linux 8, the "ol8_baseos_latest" and "ol8_appstream" repositories should already be enabled in the "/etc/yum.repos.d/oracle-linux-ol8.repo" file, and the "ol8_UEKR6" repository should already be enabled in the "/etc/yum.repos.d/uek-ol8.repo" file, but it's worth checking before you continue.

The reposync command is used to synchronize a remote yum repository to a local directory, using yum to retrieve the packages.

# /usr/bin/reposync --newest-only --download-metadata --repoid=ol8_baseos_latest -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --download-metadata --repoid=ol8_appstream -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --download-metadata --repoid=ol8_UEKR6 -p /u01/repo/OracleLinux

It takes a long time to sync the repositories the first time, so be patient. Subsequent refreshes only bring across the changed packages, so they are much quicker. The "newest-only" option reduces the total size of the download.

Resync the Repository

A resync of the Yum repositories involves repeating the reposync command, so you should script them and run them from CRON. Create a script called "/u01/repo/scripts/repo_sync.sh" with the following contents.


LOG_FILE=/u01/repo/logs/repo_sync_$(date +%Y.%m.%d).log

# Remove old logs
find /u01/repo/logs/repo_sync* -mtime +5 -delete; >> $LOG_FILE 2>&1

# Sync repositories
/usr/bin/reposync --newest-only --download-metadata --refresh --repoid=ol8_baseos_latest -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --download-metadata --refresh --repoid=ol8_appstream -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --download-metadata --refresh --repoid=ol8_UEKR6 -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1

Make the file executable.

# chmod u+x /u01/repo/scripts/repo_sync.sh

Set up a CRON job to run the script on a daily basis. The following entry runs the script each day at 01:00.

0 1 * * * /u01/repo/scripts/repo_sync.sh > /dev/null 2>&1

Setup the HTTP Server

Install the Apache HTTP servers, start it and make sure it restarts automatically on reboot.

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

If you are using the Linux firewall you will need to punch a hole for port 80.

# firewall-cmd --permanent --zone=public --add-port=80/tcp
# firewall-cmd --reload

Either set SELinux to permissive, or configure the fcontext for the repository files as shown below.

# # One-off configuration.
# dnf install -y policycoreutils-python-utils
# semanage fcontext -a -t httpd_sys_content_t "/u01/repo/OracleLinux(/.*)?"

# # Run each time the repo contents change.
# restorecon -F -R -v /u01/repo/OracleLinux

Present the repositories using the HTTP server.

# mkdir -p /var/www/html/repo/OracleLinux/ol8_baseos_latest
# ln -s /u01/repo/OracleLinux/ol8_baseos_latest/ /var/www/html/repo/OracleLinux/ol8_baseos_latest/x86_64

# mkdir -p /var/www/html/repo/OracleLinux/ol8_appstream
# ln -s /u01/repo/OracleLinux/ol8_appstream/ /var/www/html/repo/OracleLinux/ol8_appstream/x86_64

# mkdir -p /var/www/html/repo/OracleLinux/ol8_UEKR6
# ln -s /u01/repo/OracleLinux/ol8_UEKR6/ /var/www/html/repo/OracleLinux/ol8_UEKR6/x86_64

Copy the GPG key to the HTTP server.

cp /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle /var/www/html/RPM-GPG-KEY-oracle-ol8

Point Servers to the Local Repository

To allow a server to use the local Yum repositories, create a file called "/etc/yum.repos.d/local-ol8.repo" with the following contents, where "ol8-yum.localdomain" is the name of the server with the Yum repositories.

name=Oracle Linux $releasever Latest ($basearch)

name=Oracle Linux AppStream $releasever Latest ($basearch)

name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)

For more information see:

Hope this helps. Regards Tim...

Back to the Top.