Add repository oracle linux

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.

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.

#!/bin/bash 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
# 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
# # 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.

[local_ol8_baseos_latest] name=Oracle Linux $releasever Latest ($basearch) baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_baseos_latest/$basearch/ gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8 gpgcheck=1 enabled=1 [local_ol8_appstream] name=Oracle Linux AppStream $releasever Latest ($basearch) baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_appstream/$basearch/ gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8 gpgcheck=1 enabled=1 [local_ol8_UEKR6] name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch) baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_UEKR6/$basearch/ gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8 gpgcheck=1 enabled=1

Hope this helps. Regards Tim.

Читайте также:  Linux bash list file

Created: 2021-02-27 Updated: 2022-04-06

Источник

Оцените статью
Adblock
detector