Local Yum Repository for Oracle Linux 8
Local Yum Repository for Oracle Linux 8
Configure Server Repositories
Resync the Repository
Setup the HTTP Server
Point Servers to the Local Repository
Make sure the repositories of interest are available on the server,
# vim oel8-tmp.repo
[ol8_baseos_latest]
name=Oracle Linux $releasever BaseOS ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1
Install OEL8 related repo files from below command
# dnf reinstall oraclelinux-release-el8
# dnf clean packages
# dnf install oracle-epel-release-el8.x86_64 oracle-gluster-release-el8.x86_64 oracle-spacewalk-client-release-el8.x86_64 oraclelinux-developer-release-el8.x86_64 oraclelinux-release-el8.x86_64
# dnf install oracle-epel-release-el8.x86_64 oracle-gluster-release-el8.x86_64 oracle-spacewalk-client-release-el8.x86_64 oraclel
IMPORT RPM GPG KEY
# curl https://yum.oracle.com/RPM-GPG-KEY-oracle-ol8 -o RPM-GPG-KEY-oracle
# gpg --quiet --keyid-format 0xlong --with-fingerprint RPM-GPG-KEY-oracle
# yum install yum-utils createrepo
This may install some additional packages to support other repositories, depending on what repositories you already had enabled before you started the process. Let's take a look at the contents of the "/etc/yum.repos.d" directory now.
-rw-r--r--. 1 root root 216 Sep 22 08:49 oel8-tmp.repo
-rw-r--r--. 1 root root 212 Sep 24 12:41 ol8-addon.repo
-rw-r--r--. 1 root root 252 Jul 23 05:50 oracle-epel-ol8.repo
-rw-r--r--. 1 root root 246 Mar 4 2020 oracle-gluster-ol8.repo
-rw-r--r--. 1 root root 459 Dec 13 2019 oraclelinux-developer-ol8.repo
-rw-r--r--. 1 root root 1565 Apr 28 21:05 oracle-linux-ol8.repo
-rw-r--r--. 1 root root 249 Aug 5 00:59 oracle-spacewalk-client-ol8.repo
-rw-r--r--. 1 root root 470 Jul 23 05:50 uek-ol8.repo
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 /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_UEKR6" repositories should already be enabled in the "/etc/yum.repos.d/public-yum-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 --repoid=ol8_baseos_latest -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --repoid=ol8_UEKR6 -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --repoid=ol8_appstream -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --repoid=ol8_spacewalk210_client --repoid=ol8_gluster_appstream -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --repoid=ol8_developer -p /u01/repo/OracleLinux
# /usr/bin/reposync --newest-only --repoid=ol8_addons -p /u01/repo/OracleLinux
It takes a long time to sync the repositories the first time, so be patient. I waited overnight for the 32G of downloads to complete. Subsequent refreshes only bring across the changed packages, so they are much quicker. The "newest-only" option reduces the total size of the download.
Once complete, you can create the repositories from the local directories using the createrepo command.
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_baseos_latest/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_appstream/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_developer/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_gluster_appstream/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_addons/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_developer_EPEL/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_spacewalk210_client/getPackage
# /usr/bin/createrepo /u01/repo/OracleLinux/ol8_UEKR6/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 "/u01/repo/scripts/repo_sync.sh" with the following contents.
#!/bin/bash
## Download Latest Repo (RPM's) from OEL Repository 8 (OEL 8)
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 --repoid=ol8_baseos_latest -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_developer -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_developer_EPEL -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_spacewalk210_client -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_UEKR6 -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_appstream -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_gluster_appstream -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/reposync --newest-only --repoid=ol8_addons -p /u01/repo/OracleLinux >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_baseos_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_developer4/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_developer_EPEL/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_spacewalk210_client/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_UEKR6/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_gluster_appstream/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /u01/repo/OracleLinux/ol8_addons/getPackage/ >> $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.
# yum install 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.
# yum install policycoreutils-python -y
# 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_latest
# mkdir -p /var/www/html/repo/OracleLinux/ol8_developer
# mkdir -p /var/www/html/repo/OracleLinux/ol8_developer_EPEL
# mkdir -p /var/www/html/repo/OracleLinux/ol8_spacewalk210_client
# mkdir -p /var/www/html/repo/OracleLinux/ol8_UEKR6
# mkdir -p /var/www/html/repo/OracleLinux/ol8_appstream
# mkdir -p /var/www/html/repo/OracleLinux/ol8_gluster_appstream
# mkdir -p /var/www/html/repo/OracleLinux/ol8_addons
# ln -s /u01/repo/OracleLinux/ ol8_latest /getPackage /var/www/html/repo/OracleLinux/ol8_latest/x86_64
# ln -s /u01/repo/OracleLinux/ol8_developer/getPackage /var/www/html/repo/OracleLinux/ol8_developer/x86_64
# ln -s /u01/repo/OracleLinux/ol8_developer_EPEL/getPackage /var/www/html/repo/OracleLinux/ol8_developer_EPEL/x86_64
# ln -s /u01/repo/OracleLinux/ol8_spacewalk210_client/getPackage /var/www/html/repo/OracleLinux/ol8_spacewalk210_client/x86_64
# ln -s /u01/repo/OracleLinux/ol8_gluster_appstream/getPackage /var/www/html/repo/OracleLinux/ol8_gluster_appstream/x86_64
# ln -s /u01/repo/OracleLinux/ol8_UEKR6/getPackage /var/www/html/repo/OracleLinux/ol8_UEKR6/x86_64
# ln -s /u01/repo/OracleLinux/ol8_appstream/getPackage /var/www/html/repo/OracleLinux/ ol8_appstream/x86_64
# ln -s /u01/repo/OracleLinux/ol8_addons/getPackage /var/www/html/ OracleLinux/ol8_addons/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-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_latest/$basearch/
gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8
gpgcheck=1
enabled=1
[local_ol8_developer]
name=Latest Oracle Linux $releasever Development Packages ($basearch)
baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_developer/$basearch/
gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8
gpgcheck=1
enabled=1
[local_ol8_developer_EPEL]
name=Latest Oracle Linux $releasever EPEL Packages for Development ($basearch)
baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_developer_EPEL/$basearch/
gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8
gpgcheck=1
enabled=1
[local_ol8_appstream]
name=Oracle Linux $releasever Application Stream ($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_gluster_appstream]
name= Oracle Linux $releasever Gluster Appstream($basearch)
baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_gluster_appstream/$basearch/
gpgkey=http://ol8-yum.localdomain/RPM-GPG-KEY-oracle-ol8
gpgcheck=1
enabled=1
[local_ol8_spacewalk210_client]
name=Latest Spacewalk Client 2.10 for Oracle Linux 8($basearch)
baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_spacewalk210_client/$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
[ol8_addons]
name=Oracle Linux $releasever Addons Packages ($basearch)
baseurl=http://ol8-yum.localdomain/repo/OracleLinux/ol8_addons/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=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
Comments
Post a Comment