In today’s article, we will explain how to use Oracle Linux as a local repository for its own series.
Oracle Linux 7 operating system can receive updates on security and improvement like other operating systems.
These updates can be made from the internet depending on the version it is connected to, or it can be done from an Oracle Linux 7 installed server within its own structure in order not to tire the internet traffic and to control the current updates.
Today we will tell you how to do this procedure. Our process will be done in two separate phases as Server and Client.
First of all, we will need an Oracle Linux 7 machine for which we will make a local repository and a CSI (Customer Support Identifer), that is, an Oracle support account.
First, we start with the server side.
First of all, we install the createrepo from Yum tools.
1 |
# yum install yum-utils createrepo |
Then we register on Oracle CSI.
1 |
# uln_register |
If you have configured the Oracle Linux 7 operating system with a default installation, the ol7_latest and ol7_UEKR4 repository ”/etc/yum.repos.d/public-yum-ol7.repo ” should come installed. You can make the controls from the relevant location.
By running the following four commands in order, we synchronize the Repository packages to our own server over the internet.
This process will vary depending on the file size and your internet speed.
1 2 3 4 |
# yum install yum-plugin-fastestmirror # /usr/bin/reposync --newest-only --repoid=ol7_latest -p /repo/OracleLinux # /usr/bin/reposync --newest-only --repoid=ol7_UEKR4 -p /repo/OracleLinux # /usr/bin/reposync --newest-only --repoid=ol7_UEKR5 -p /repo/OracleLinux |
After the installation process is completed, we can prepare our local infrastructure with the createrepo command.
1 2 3 |
# /usr/bin/createrepo /repo/OracleLinux/ol7_latest/getPackage/ # /usr/bin/createrepo /repo/OracleLinux/ol7_UEKR4/getPackage/ # /usr/bin/createrepo /repo/OracleLinux/ol7_UEKR5/getPackage/ |
After our local repository file is prepared, we open them to access via a web server. The client side will read updates from an xml file. We set up and activate our web server.
1 2 3 |
# yum install httpd -y # systemctl start httpd # systemctl enable httpd |
We make our firewall settings and port 80 is opened to access.
1 2 |
# firewall-cmd --permanent --zone=public --add-port=80/tcp # firewall-cmd --reload |
If we are using SeLinux, we add the relevant configuration.
1 2 3 4 5 6 |
# # 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 |
In the first step, we created the repository. We will access them with the web server. We assign the relevant directories from our web server with the symbolic link.
1 2 3 4 5 6 7 8 |
# mkdir -p /var/www/html/repo/OracleLinux/ol7_latest # ln -s /repo/OracleLinux/ol7_latest/getPackage/ /var/www/html/repo/OracleLinux/ol7_latest/x86_64 # mkdir -p /var/www/html/repo/OracleLinux/ol7_UEKR4 # ln -s /repo/OracleLinux/ol7_UEKR4/getPackage/ /var/www/html/repo/OracleLinux/ol7_UEKR4/x86_64 # mkdir -p /var/www/html/repo/OracleLinux/ol7_UEKR5 # ln -s /repo/OracleLinux/ol7_UEKR5/getPackage/ /var/www/html/repo/OracleLinux/ol7_UEKR5/x86_64 |
We upload our GPD file to our web server.
1 |
cp /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle /var/www/html/RPM-GPG-KEY-oracle-ol7 |
We’re done on the server side. Now we can move on to the client side.
Our job in this step is quite simple. With our nano editor, we create a local-ol7.repo file by entering the yum.repos.d subdirectory under the etc directory.
1 |
#nano /etc/yum.repos.d/local-ol7.repo |
We replace the following lines in the editor with the “repo.server.local” part with our own server name, add the remaining parts exactly and save and exit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[local_ol7_latest] name=Oracle Linux $releasever Latest ($basearch) baseurl=http://repo.sunucu.local/repo/OracleLinux/ol7_latest/$basearch/ gpgkey=http://repo.sunucu.local/RPM-GPG-KEY-oracle-ol7 gpgcheck=1 enabled=1 [local_ol7_UEKR4] name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch) baseurl=http://repo.sunucu.local/repo/OracleLinux/ol7_UEKR4/$basearch/ gpgkey=http://repo.sunucu.local/RPM-GPG-KEY-oracle-ol7 gpgcheck=1 enabled=1 [local_ol7_UEKR5] name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch) baseurl=http://repo.sunucu.local/repo/OracleLinux/ol7_UEKR5/$basearch/ gpgkey=http://repo.sunucu.local/RPM-GPG-KEY-oracle-ol7 gpgcheck=1 enabled=1 |
Now all the updates made on the client side will come from the local repository.
So how do we get the newly released update packages on the server side?
Let’s create a script called repo.sh in the scripts subdirectory in the repo directory.
1 |
#nano /repo/scripts/repo.sh |
Let’s paste the script below without changing it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#!/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 --newest-only --repoid=ol7_latest -p /repo/OracleLinux >> $LOG_FILE 2>&1 /usr/bin/reposync --newest-only --repoid=ol7_UEKR4 -p /repo/OracleLinux >> $LOG_FILE 2>&1 /usr/bin/reposync --newest-only --repoid=ol7_UEKR5 -p /repo/OracleLinux >> $LOG_FILE 2>&1 /usr/bin/createrepo /repo/OracleLinux/ol7_latest/getPackage/ >> $LOG_FILE 2>&1 /usr/bin/createrepo /repo/OracleLinux/ol7_UEKR4/getPackage/ >> $LOG_FILE 2>&1 /usr/bin/createrepo /repo/OracleLinux/ol7_UEKR5/getPackage/ >> $LOG_FILE 2>&1 |
We give execute permission for the script.
1 |
# chmod u+x /repo/scripts/repo.sh |
Finally, let’s add it to the crontab.
1 |
0 1 * * * /repo/scripts/repo.sh > /dev/null 2>&1 |
All processes are ready for local repository.