Oracle 8i | Oracle 9i | Oracle 10g | Oracle 11g | Oracle 12c | Miscellaneous | PL/SQL | SQL | Oracle RAC | Oracle Apps | Linux

Create a Local Yum Repository for Oracle Linux 6

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

Repository Creation

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

# yum install yum-utils createrepo

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

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

If you've done a default installation of Oracle Linux 6, the "public_ol6_latest" and "public_ol6_UEK_latest" repositories should already be enabled in the "/etc/yum.repos.d/public-yum-ol6.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 --repoid=public_ol6_latest --repoid=public_ol6_UEK_latest \
                    --repoid=public_ol6_UEKR3_latest -p /repo/OracleLinux

It takes a long time to sync the repositories the first time, so be patient. I waited overnight for the 27G of downloads to complete. Subsequent refreshes only bring across the changed packages, so they are much quicker.

Once complete, you can create the repositories from the local directories using the createrepo command.

# /usr/bin/createrepo /repo/OracleLinux/public_ol6_latest/getPackage/
# /usr/bin/createrepo /repo/OracleLinux/public_ol6_UEK_latest/getPackage/
# /usr/bin/createrepo /repo/OracleLinux/public_ol6_UEKR3_latest/getPackage/

Resync the Repository

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

#!/bin/bash

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

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

# Sync repositories
/usr/bin/reposync --repoid=public_ol6_latest --repoid=public_ol6_UEK_latest \
                  --repoid=public_ol6_UEKR3_latest -p /repo/OracleLinux >> $LOG_FILE 2>&1

/usr/bin/createrepo /repo/OracleLinux/public_ol6_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /repo/OracleLinux/public_ol6_UEK_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /repo/OracleLinux/public_ol6_UEKR3_latest/getPackage/ >> $LOG_FILE 2>&1

Make the file executable.

# chmod u+x /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 * * * /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.

# yum install httpd
# service httpd start
# chkconfig httpd on

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

# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# service iptables save

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

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

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

Present the repositories using the HTTP server.

# mkdir -p /var/www/html/repo/OracleLinux/OL6/latest
# ln -s /repo/OracleLinux/public_ol6_latest/getPackage/ /var/www/html/repo/OracleLinux/OL6/latest/x86_64

# mkdir -p /var/www/html/repo/OracleLinux/OL6/UEK/latest
# ln -s /repo/OracleLinux/public_ol6_UEK_latest/getPackage/ /var/www/html/repo/OracleLinux/OL6/UEK/latest/x86_64

# mkdir -p /var/www/html/repo/OracleLinux/OL6/UEKR3/latest
# ln -s /repo/OracleLinux/public_ol6_UEKR3_latest/getPackage/ /var/www/html/repo/OracleLinux/OL6/UEKR3/latest/x86_64

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-ol6.repo" with the following contents, where "ol6-yum.localdomain" is the name of the server with the Yum repositories.

[local_ol6_latest]
name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://ol6-yum.localdomain/repo/OracleLinux/OL6/latest/$basearch/
gpgkey=http://ol6-yum.localdomain/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[local_ol6_UEK_latest]
name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://ol6-yum.localdomain/repo/OracleLinux/OL6/UEK/latest/$basearch/
gpgkey=http://ol6-yum.localdomain/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

[local_ol6_UEKR3_latest]
name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://ol6-yum.localdomain/repo/OracleLinux/OL6/UEKR3/latest/$basearch/
gpgkey=http://ol6-yum.localdomain/RPM-GPG-KEY-oracle-ol6
gpgcheck=1
enabled=1

You may also want to consider installing the following package, to make sure you pick the fastest mirror, which should be your local one.

# yum install yum-plugin-fastestmirror

For more information see:

Hope this helps. Regards Tim...

Back to the Top.