What You See Is What You Get Element

How to create a local Unbreakable Linux Network mirror

by Jared Greenwald and Avi Miller

Table of Contents

Published June 2012, Updated November 2013

This document explains how to create a local mirror of the Unbreakable Linux Network repositories and configure yum to install and update packages from these repositories.

Want to comment on this article? Post the link on Facebook's OTN Garage page.  Have a similar article to share? Bring it up on Facebook or Twitter and let's discuss.

Prerequisites

Ensure you have the following prerequisites:

  • A server running Oracle Linux 5 or Oracle Linux 6. Note that while Oracle Linux 5 is supported, Oracle strongly recommends using Oracle Linux 6.
  • A valid Oracle Linux customer support identifier (CSI). To purchase Oracle Linux support, go to the online Oracle Linux Store or contact your sales representative.
  • A valid Oracle Single Sign-On account and an activated Unbreakable Linux Network account.
  • Sufficient memory to create the yum metadata. At least 6GB of RAM is recommended to create the metadata for Oracle Linux 5 repositories, but at least 2GB is required.
  • Sufficient disk space to store a local copy of the mirrored channels. See disk storage requirements for minimum required disk space.

Server setup

The following steps describe how to mirror packages from selected channels on the Unbreakable Linux Network and make them available from a local yum server. You can create and host i386, x86_64, and ia64 repositories on the same server.

  1. Ensure that you have activated your Oracle Linux CSI and enabled your account on the Unbreakable Linux Network.
  2. Ensure that the yum-rhn-plugin RPM is installed and plugins=1 is enabled in /etc/yum.conf.
  3. Register the server with the Unbreakable Linux Network:

    For Oracle Linux 5:

    1. Import the RPM GPG key as the root user:
      # rpm --import /usr/share/rhn/RPM-GPG-KEY
    2. Run up2date in text mode:
      # up2date-nox --register
    3. Register the server by entering your Oracle Single Sign-On username, password and a valid CSI.

    For Oracle Linux 6:

    1. Run the uln_register command as the root user:
      # uln_register
    2. Register the server by entering your Oracle Single Sign-On username, password and a valid CSI.
  4. Enable the yum server option for your newly registered server:
    1. Log in to the Unbreakable Linux Network with the username and password that you used to register the server.
    2. On the Systems tab, click the link named for your server in the list of registered servers.
    3. On the System Detail page, click Edit.
    4. On the Edit System Properties page, select the Yum Server checkbox and click Apply Changes.

After registration with ULN, the server is automatically subscribed to the appropriate latest channel. You need to manually register the server to the correct addons channel to install the uln-yum-mirror package. If you are using Oracle Linux 5 as your ULN mirror server, subscribe to the el5_<arch>_addons channel. If you are using Oracle Linux 6, subscribe to the ol6_<arch>_addons channel.

  1. Subscribe the server to to the addons channel that is appropriate to the release of Oracle Linux installed on the server.
    1. On the System Details page, click Manage Subscriptions.
    2. Select the required channels from the Available Channels list and click > to add them to the Subscribed Channels list.
    3. When you have set up the Subscribed Channels list, click Save Subscriptions.

      If you want to add an additional channel to your yum mirror, add it to the Subscribed Channels list on ULN. The next time the uln-yum-mirror script runs, it automatically mirrors any additional channels that have been added. Disable server updates for any channels that you add as described in configuring the server for updates.

  2. Install the uln-yum-mirror package as the root user:
    # yum install uln-yum-mirror

    This command installs the /usr/bin/uln-yum-mirror script and automatically configures a daily cronjob to update your local yum repositories. You can adjust the configuration of the script by editing the /etc/sysconfig/uln-yum-mirror file. Configuration options are discussed in script configuration options.

  3. Create a yum repository base directory in /var/www/html.
    # mkdir -p /var/www/html/yum

    This directory will house the repository. Make sure that the yum repository owner has read and write permission on this directory.

  4. Enable and start the Apache web server.
    # chkconfig httpd on
    # service httpd start

How to configure the server for updates

To configure the server to be able to update itself from the local mirror, perform the following steps:

  1. Run the following command to get a list of channels being mirrored from ULN:
    # yum repolist
    Loaded plugins: rhnplugin, security
    This system is receiving updates from ULN.
    0 packages excluded due to repository protections
    repo id                   repo name                                                                       status
    ol6_x86_64_latest         Oracle Linux 6 Latest (x86_64)                                                  17,957
    ol6_x86_64_UEKR3_latest   Unbreakable Enterprise Kernel Release 3 for Oracle Linux 6 (x86_64) - Latest    41
    

    In the above example, the server is mirroring ol6_x86_64_latest and ol6_x86_64_UEKR3_latest.

  2. Edit /etc/yum/pluginconf.d/rhnplugin.conf and set all the channels being mirrored from ULN as disabled by adding the following stanza for each channel:
    [<repo id>]
    enabled=0
    
    For example, to disable the channels listed in the above example, add the following two stanzas:
    [ol6_x86_64_latest]
    enabled=0
    
    [ol6_x86_64_UEKR3_latest]
    enabled=0
    
  3. Follow the client setup procedure to configure the server to install updates from itself.

This process will disable the ULN channels from being accessed by yum during normal operation but will not affect the uln-yum-mirror script functionality. If any channels are added on ULN, those channels must also be disabled in /etc/yum/pluginconf.d/rhnplugin.conf. Do NOT set enabled=0 in the [main] section of /etc/yum/pluginconf.d/rhnplugin.conf as this will disable the plugin completely and prevent uln-yum-mirror from being able to mirror ULN content.

How the repository synchronization works

The initial synchronisation will be triggered automatically overnight by the configured cronjob (unless manually disabled). If you have disabled the cronjob, run the uln-yum-mirror script manually to build the local yum repositories.

By default, the uln-yum-mirror is configured to run once a day via an /etc/cron.daily/uln-yum-mirror script. You can disable the automatic daily anacron job by editing /etc/sysconfig/uln-yum-mirror and setting CRON_ENABLED to 0.

Note: When the script first runs, it can take several days to complete, depending on the number of channels that are being mirrored and the available network bandwidth.

Mirror configuration options

The uln-yum-mirror script is controlled by the /etc/sysconfig/uln-yum-mirror configuration file. The following configuration options are available:

SRC = [ 0 | 1 ]
The SRC parameter determines whether or not the script also mirrors the associated .src.rpm files. The default is 0 which means the source packages are not mirrored. Change the value to 1 to include source packages in the mirror.
ALL_PKGS = [ 0 | 1 ]
The ALL_PKGS parameter specifies whether the script mirrors all available packages or just the latest packages in each channel. The default is 1 which means that all versions of every available package is mirrored. Set this to 0 to only download the latest version of each package.
CRON_ENABLED = [ 0 | 1 ]
The CRON_ENABLED parameter determines whether or not the daily anacron job is enabled for automatic mirroring of channels on a daily basis. If this parameter is set to 0, the uln-yum-mirror script will need to be manually run to update the local mirror.
HARDLINK_RPMS
The HARDLINK_RPMS parameter specifies whether hardlinkpy will run after the channel sychronization completes. This process will reduce the overall amount of disk space consumed by the repository by hardlinking identical packages on the filesystem.
LOG_OUTPUT
The LOG_OUTPUT parameter specifies whether the output of the automatic cronjob is logged to /var/log/uln-yum-mirror.log.
REP_BASE
REPO_FILE_DIR
YUM_GLOBAL_CACHE
These parameters specify the paths of the mirrored channels and yum cache directory. Do not change these settings unless you need to customize the configuration of the web server.
REP_ENG
REP_EL
REP_OL
REP_OVM
REP_UNK
These parameters determine the repository name for each of the various channel types. You can configure an alternative name for each of the channel groups. The REP_ENG type is used by the Oracle Engineered Systems, e.g. Exadata and Exalogic.

Client setup

After you have set up the repository server, you can configure clients to use the repositories.

Setting up Oracle Linux clients

To configure an Oracle Linux server to receive updates from the local yum server, perform the following steps:

  1. Import the GPG key as the root user:
    # rpm --import /usr/share/rhn/RPM-GPG-KEY
  2. Create a yum repository configuration file in /etc/yum.repos.d using the following format:

    [<channel_label>]
    name=<Channel Description>
    baseurl=http://<repository_server>/yum/<repository path>
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
    enabled=1

    For example:

    [local_ol6_x86_64_latest]
    name=Oracle Linux $releasever - $basearch - latest
    baseurl=http://<repository_server>/yum/OracleLinux/OL6/latest/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
    enabled=1

    You can browse http://<repository_server>/yum/ to find the baseurl for each repository. You can also use the $releasever and $basearch parameters.

  3. To test that yum is correctly configured to install and update packages from your local yum repository:
    1. Clear the yum metadata cache:
      # yum clean metadata
    2. Ensure the correct channels are configured:
      # yum repolist
      Loaded plugins: rhnplugin, security
      This system is receiving updates from ULN.
      0 packages excluded due to repository protections
      repo id                         repo name                                                                       status
      local_ol6_x86_64_latest         Oracle Linux 6 Latest (x86_64)                                                  17,957
      local_ol6_x86_64_UEKR3_latest   Unbreakable Enterprise Kernel Release 3 for Oracle Linux 6 (x86_64) - Latest    41
      

      To ensure that your local repositories do not conflict with upstream repositories, prefix their names with the string "local_".

Review the Oracle Linux Unbreakable Linux Network User's Guide for more information on using yum to install new packages and upgrade existing packages.

Setting up Oracle VM 3 clients

Oracle VM Manager is used to configure the repository used by the Oracle VM Servers it manages.

  1. For an Oracle VM 3 configuration, add the repository URL to the Oracle VM 3 Manager configuration by selecting Tools -> Server Update Management (YUM) and then entering the following information:

    YUM Base URL:
    http://<repository_server>/yum/OracleVM/OVM3/3.0/latest/x86_64/
    Enable GPG Key:
    Yes
    YUM GPG Key:
    file:///etc/pki/rpm-gpg/RPM-GPG-KEY

    Depending on your mirror configuration, you could use one of the following for the yum base URL instead:

    http://<repository_server>/yum/OracleVM/OVM3/3.0/base/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.0.2/base/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.0.3/base/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.0/patch/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.0.3/patch/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.1.1/base/x86_64/
    http://<repository_server>/yum/OracleVM/OVM3/3.1.1/patch/x86_64/
    

Oracle VM Manager should be used to upgrade Oracle VM Servers. Check the Oracle VM documentation for instructions.

Tables

Disk storage requirements

The following tables contain estimates of the minimum disk space that is required to mirror the latest Oracle Linux and Oracle VM channels. These estimates are correct at the time of writing but are likely to change over time.

Table 1. Minimum Space Requirements for current Oracle Linux 5 Channels
Channel Label Latest Binaries All Binaries Latest Source & Binaries All Source & Binaries
el5_unsupported_<arch>_latest
2 GB
10 GB
2 GB
16 GB
el5_<arch>_addons
500 MB
4 GB
500 MB
6 GB
el5_<arch>_latest
4 GB
40 GB
8 GB
80 GB
el5_<arch>_oracle
1 GB
3 GB
1 GB
3 GB
ol5_u10_<arch>_base
4 GB
4 GB
7 GB
7 GB
ol5_u10_x86_64_patch
500 MB
1 GB
1 GB
2 GB
ol5_<arch>_ksplice
4 GB
30 GB
4 GB
30 GB
ol5_<arch>_latest
4 GB
25 GB
8 GB
45 GB
ol5_<arch>_UEK_latest
150 MB
4 GB
200 MB
6 GB

Table 2. Minimum Space Requirements for current Oracle Linux 6 Channels
Channel Label Latest Binaries All Binaries Latest Source & Binaries All Source & Binaries
ol6_playground_<arch>_latest
100 MB
3 GB
200 MB
6 GB
ol6_u4_<arch>_base
5 GB
5 GB
10 GB
10 GB
ol6_u4_<arch>_patch
2 GB
5 GB
3 GB
10 GB
ol6_<arch>_addons
300 MB
3 GB
300 MB
3 GB
ol6_<arch>_Dtrace_latest
100 MB
100 MB
200 MB
200 MB
ol6_<arch>_ksplice
5 GB
30 GB
5 GB
30 GB
ol6_<arch>_latest
7 GB
30 GB
15 GB
65 GB
ol6_<arch>_MySQL
200 MB
1 GB
200 MB
1 GB
ol6_<arch>_MySQL56
250 MB
500 MB
300 MB
500 MB
ol6_<arch>_oracle
350 MB
1 GB
350 MB
1 GB
ol6_<arch>_UEK_latest
100 MB
3 GB
200 MB
6 GB
ol6_<arch>_UEKR3_latest
200 MB
300 MB
250 MB
500 MB

Table 3. Minimum Space Requirements for current Oracle VM channels
Channel Label Latest Binaries All Binaries Latest Source & Binaries All Source & Binaries
ovm3_<arch>_latest
250 MB
2 GB
2 GB
4 GB

See also

About the authors

  • Jared Greenwald is a Senior Developer at Oracle and one of the project leads for the Unbreakable Linux Network.
  • Avi Miller is a Product Management Director at Oracle and is the product manager for the Unbreakable Linux Network.
Revision 2.1, 11/26/2013

See sysadmin-related content for all Oracle technologies by following OTN Systems on Facebook and Twitter.