Local Yum Repos for Oracle Linux

At least one person asked me why I did this, so I’ll start by explaining the motivation for setting up my own mirror of Yum repositories freely available on public-yum.oracle.com.

It comes down to 5 main reasons:

  1. Wanting my Oracle Linux 6 installation can take advantage of the “latest” repositories
  2. Wanting the ability to update to a consistent version by using repositories I control
  3. Reducing the amount of data I download over the internet
  4. A desire to learn how to set up a Yum repository [mirror]
  5. Making my updates faster as they only have to retrieve packages from the LAN

When I first looked into setting up a Yum mirror I found a number of articles covering how to do so via rsync and I then found this post where one of the comments suggests that allowing rsync access to public-yum.oracle.com would be nice. This made me realised that the rsync approach wasn’t going to work for the Oracle Linux repositories (it seems the suggestion was well received so this may change in the future). I also found a OTN article covering “How to Create a Local Yum Repository for Oracle Linux“. I eagerly started to read and quickly hit a snag for me in the prerequisites section:

Have valid customer support identifier (CSI)

I don’t have a CSI. My customers all have CSIs, because they run Oracle in production. I don’t have a CSI as I only run the OTN versions of Oracle software in my lab so that I can test out things I don’t have opportunity, access or time to test on client sites.

Anyway, with a little bit of reading around I found a way to create local mirrors of the Oracle Linux 6 Latest and Oracle UEK Latest repositories.

What follows was carried out on a VM, but there is no reason why any of this won’t work equally on a physical host. If you encounter any problem replicating what I’ve done here then please comment and I’ll gladly try to help.

1) Allocating Storage

You’re going to need a reasonable amount of storage for this. My “repos” file system currently holds 24G of data and that is just for Oracle Linux 6 Latest and Oracle UEK Latest. I created a dedicated file system for my repositories on a LVM volume, but won’t cover that here. Allocate the storage as you see fit, but you’re going to want at least the 24G quoted.

2) Create Directory For Repos

As mentioned above, I have a dedicated file system for my repositories. It’s mounted under /repos and I’ll include that in all the code listings that follow. If you chose to use a different directory structure then clearly you’ll need to make the required changes.

# mkdir -p /repos/x86_64/

3) Install yum-utils

yum-utils includes a couple of commands you’re going to need for this, reposync and createrepo.

# yum -y install yum-utils

4) Setup Repositories

Follow the instructions on public-yum.oracle.com in order to set up the Oracle repositories.

By default reposync will create a local copy of all your enabled repositories, but it is also possible to specify the name of the repo[s] you want to sync on the command line using the “r” or “repoid” flag. I use this option as I want to have my local repositories enabled on all my Oracle Linux 6 hosts, including the repository machine, but only want reposync to run for the public-yum.oracle.com repositories I want to mirror locally. This means that I do not enable any of the repositories in the public-yum-ol6.repo file downloaded from Oracle and create a new .repo file for my local repositories that I can distribute to all machines.

5) Run reposync

Running reposync is as simple as the command below:

# /usr/bin/reposync --repoid=ol6_UEK_latest --repoid=ol6_latest -p /repos/x86_64

6) Run createrepo

Once the repositories are downloaded to the local file system you need to run createrepo in order to create the repository metadata:

# createrepo /repos/x86_64/ol6_UEK_latest/getPackage/
# createrepo /repos/x86_64/ol6_latest/getPackage/

The “update” option for createrepo looked attractive in the man page, but whenever I used it the process was killed by the OOM Killer and I haven’t investigated in detail.

7) Allowing Web Access

In order to make use of the repositories they need to be exposed to the machines requiring access. HTTP is as good a way as any for my purposes, so I installed Apache (yum -y install httpd), ensured it would restart on reboot (chkconfig httpd on) and created symbolic links to my repositories:

# cd /var/www/html/repo/OracleLinux/OL6
# ln -s /repos/x86_64/ol6_UEK_latest/getPackage/ ./UEK/latest/x86_64
# ln -s /repos/x86_64/ol6_latest/getPackage/ ./latest/x86_64

8) Script for Updating Mirrors

Once I’d got it working I created a very simple shell script to allow me update whenever I appropriate:

LOG_FILE=/repos/logs/repo_cron_$(date +%Y.%m.%d).log
/usr/bin/reposync --repoid=ol6_UEK_latest --repoid=ol6_latest -p /repos/x86_64 >> $LOG_FILE 2>&1
/usr/bin/createrepo /repos/x86_64/ol6_UEK_latest/getPackage/ >> $LOG_FILE 2>&1
/usr/bin/createrepo /repos/x86_64/ol6_latest/getPackage/ >> $LOG_FILE 2>&1

It’s then just a matter of pointing my Oracle Linux 6 installations at my local repository.

For reference my repo file is as follows (with hostnames removed)

name=Oracle Linux $releasever Latest ($basearch)
baseurl=http://<hostname removed>/repo/OracleLinux/OL6/latest/$basearch/
gpgkey=http://<hostname removed>/RPM-GPG-KEY-oracle-ol6

name=Latest Unbreakable Enterprise Kernel for Oracle Linux $releasever ($basearch)
baseurl=http://<hostname removed>/repo/OracleLinux/OL6/UEK/latest/$basearch/
gpgkey=http://<hostname removed>/RPM-GPG-KEY-oracle-ol6

8 thoughts on “Local Yum Repos for Oracle Linux

  1. Hi Martin,
    Nice post!

    I’ve got a completely (almost) unrelated question, and that is what kind of hw/sw setup you’ve got for your lab. (Whitebox/server, amount of ram, number of cpu’s, hypervisor (if yes which one?), storage etc)?
    I’m in the process of rebuilding my own lab, which has been running ovm 2.1/openfiler for quite some time. The hw is quite old so its time for a refresh.
    Fun times (potentially)!


    • Hi Peter,

      My main play environment consists of 3 quad core machines, all of which are PC grade equipment:

      • Intel i7-920, 12GB RAM, 2 x 500GB SATA II HDD, 2 x 256GB SATA III SSD
      • Intel i7-860, 8GB RAM, 2 x 1TB SATA II HDD
      • AMD Phenom X4 9350e, 8GB RAM, 3 x 500GB SATA II HDD

      I started off using Oracle VM when I first bought the AMD machine and started playing with virtualisation, but have since moved to KVM (Kernel-based Virtual Machine). I use VirtualBox on my laptop for simple VM testing scenarios, but anything that involves multiple RAC nodes or more than 2 VMs running at a time is [generally] confined to my desktop machines. I might justify a new laptop in the not too distant future.

      Right now the machines look like this:

      • i7-920 – Ubuntu 12.04 as the host OS with 4 x Oracle Linux 6.3, 1 x Windows XP and 1 x Solaris 11.1 as guests using KVM
      • i7-860 – Solaris 11.1 with a few zones
      • Phenom X4 9350e – Oracle Linux 6.3 as the host OS with 4 x Oracle Linux 6.3 and 1 x Windows XP as guests running using KVM

      Doing shared disks in KVM is easy enough, so I haven’t used iSCSI for my RAC environments since moving from OVM/Xen. I believe that although the device name mapping appears to be consistent based on the KVM VM XML configuration file it isn’t guaranteed, so I use ASMLib – I didn’t find a way to get an unique ID for virtio devices so couldn’t see a way to use udev in a guaranteed consistent way.

      Probably more information than you were looking for, but hopefully useful all the same 🙂

  2. Hi Martin,
    Thank you, this is exactly the kind of information I was after! I dont know why, but I always get excited about other people´s lab environments 😉

    The plan now is: a i7-2600 (or 3820),32G RAM, and 2 ssd’s for good measure. I’ll probably use the ssd’s for db-storage. I’ve also got 3x1TB SATAII that I’ll use for os/db-installs etc. I’m also considering getting a raid-card but the jury is still out on that.
    I might also turn the old machine into a pure storagebox (openfiler/nexenta etc). If I go down the OVM3 path it might be useful, I guess.
    I was considering a supermicro server to be able to have a remote console but I decided against it in the end.

    As for hypervisor I’m torn between esxi and Oracle VM. OVM2 was easy to use, OVM3 is a totally different beast as you become more dependent on external storage. Esx is easy and just works. I guess I have to try them out.

    I alternate between kvm and Virtualbox on my work-laptop and both have been working fine.

    Thanks again!

  3. Hi Pete,
    I know at least part if it may sound obvious but your lab hardware/sotware/storage choice should probably depend on what your objectives for the lab are.
    To start with I would probably suggest buying i7-3XXX and not bother with i7-2XXX, purly on the ground that i7-2XXX series is effectively an generation old CPU and you don’t want to buy old hardware for your new lab 🙂 The other suggestion would be that if you are planning to use SSDs for your storage then buying second box and converting it into pure storage box will probably make less sense because you will be limited by your ethernet card, and I assume you most likely won’t buy 10gig ethernet or infiniband for you home lab.
    Similar logic apply to the raid card, sort of it depends why you want to buy it. Decent card is not cheap, and software raid is usually better then cheap card. If it’s for write cache it’s fair enough (but then do you need SSDs), but if it’s for mirorring/raid then both openfiler and nexenta can do software RAID for you. If you are running KVM you can also setup software raid on your main box, and then you don’t need to spend extra on raid card and/or storage server. I’m not sure if OVM3 can do it, but from what I know esxi can’t.


  4. Hi Pawel,
    The reason for getting a RAID-card would (mainly) be if I decide to go with esx, as there is no way (to my knowledge) to do software raid in esx, it sort of assumes that you have external storage. Same goes for OVM3, internal storage is just painful to work with (and software raid doesnt work). If I stick with OVM2 then its possible to do software-raid, but then OVM2 is really old…
    It also turns out I’ll probably be able to get a lsi 9265-8i card from one of our retired servers at work so it wont be an extra expense (supposing the card actually stilll works).
    If I’m going to setup a storage server I’ll be using the old lab-gear with existing disks.

    As for the CPU, I actually decided on the i7-3820 yesterday 😉 I’m also going for a motherboard with 8 dimm slots capable of 64Gb.
    Once everything is delivered I’ll set it up and start testing the various hypervisors, but if the lsi card actually works I’ll probably go for esx and not worry about setting up a storage server. Its just easier to keep everything internal and not be dependant on external storage. If it doesnt we’ll have to see.


  5. Pingback: Local mirror of Oracle public yum | Hazrul Nizam's Journal

  6. Pingback: Local mirror of Oracle public yum – UPDATED | Hazrul Nizam's Journal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s