2.8 Creating and Using a Local ULN Mirror

2.8.1 Prerequisites for the Local ULN Mirror
2.8.2 Setting up a Local ULN Mirror
2.8.3 ULN Mirror Configuration
2.8.4 Updating the Repositories on a Local ULN Mirror
2.8.5 Configuring yum on a Local ULN Mirror
2.8.6 Configuring Oracle Linux Yum Clients of a Local ULN Mirror

The following sections describe how to create and use a yum server that acts as a local mirror of the ULN channels.

2.8.1 Prerequisites for the Local ULN Mirror

The system that you want to set up as a local ULN mirror must meet the following criteria:

  • You must have registered the system with ULN. See The Unbreakable Linux Network.

  • The system must be running Oracle Linux 5 or Oracle Linux 6.

  • The system must have a least 6 GB of memory to create the yum metadata.

  • The system must have enough disk space to store copies of the packages that it hosts. The following table shows the approximate amount of space that is required for Oracle Linux channels:

    Oracle Linux Channel

    Space Required per Channel for Binaries Only

    Space Required per Channel for Both Binaries and Source

    [oe]l*_latest

    Up to 10 GB

    Up to 15 GB

    [oe]l*_addons

    600 MB

    1 GB

    [oe]l*_oracle

    1 GB

    Not applicable

    [oe]l*_base

    3 GB

    5.5 GB

    [oe]l*_patch

    1 GB

    2 GB

    The next table shows the approximate amount of space that is required for Oracle VM channels:

    Oracle VM Channel

    Space Required per Channel for Binaries Only

    Space Required per Channel for Both Binaries and Source

    ovm*_latest

    500 MB

    1 GB

    ovm*_base

    400 MB

    800 MB

    ovm*_patch

    100 MB

    200 MB

2.8.2 Setting up a Local ULN Mirror

To set up a local system as a local ULN mirror:

  1. Using a browser, log in at http://linux.oracle.com with the ULN user name and password that you used to register the system, and configure its properties on ULN as follows:

    1. On the Systems tab, click the link named for your system in the list of registered machines.

    2. On the System Details page, click Edit.

    3. On the Edit System Properties page, select the Yum Server check box and click Apply Changes.

    4. On the System Details page, click Manage Subscriptions.

    5. On the System Summary page, select channels from the list of available or subscribed channels and click the arrows to move the channels between the lists.

      Modify the list of subscribed channels to include the channels that you want to make available to local systems.

      Note

      You must subscribe the system to the latest and addons channels for the installed operating system release (Oracle Linux 5 or Oracle Linux 6) and the system architecture (i386 or x86-64) to be able to install the yum-uln_mirror package. This package contains the uln-yum-mirror script that enables the system to act as a local ULN mirror.

      For example, the following table shows some examples of the channels that are available for Oracle Linux 6 on the x86_64 architecture.

      Channel

      Description

      ol6_ga_x86_64_base

      All packages for Oracle Linux 6 as initially released. This channel does not include errata.

      ol6_x86_64_addons

      Oracle Linux 6 add ons, including the yum-uln_mirror package.

      ol6_x86_64_ksplice

      Oracle Ksplice clients, updates, and dependencies for Oracle Linux 6. Note that access to this channel requires an Oracle Linux Premier Support account.

      ol6_x86_64_latest

      All packages released for Oracle Linux 6, including the latest errata packages.

      ol6_x86_64_UEK_latest

      Latest Unbreakable Enterprise Kernel Release 2 packages for Oracle Linux 6.

      ol6_x86_64_UEKR3_latest

      Latest Unbreakable Enterprise Kernel Release 3 packages for Oracle Linux 6.

      If you subsequently update the list of channels to which the system is subscribed, the uln-yum-mirror script updates the channels that the system mirrors. If you want to be able to use yum to update the server from the repositories that it hosts rather than from ULN, follow the procedure in Section 2.8.5, “Configuring yum on a Local ULN Mirror”.

      If you have an Oracle Linux Premier Support account and you want the yum server to host Ksplice packages for local Ksplice offline clients, subscribe to the Ksplice for Oracle Linux channels for the architectures and Oracle Linux releases that you want to support.

      For a complete and up-to-date list of the available release channels, log on to ULN at http://linux.oracle.com.

    6. When you have finished selecting channels, click Save Subscriptions and log out of ULN.

  2. Install the Apache HTTP server.

    # yum install httpd
  3. Create a base directory for the yum repositories, for example /var/yum or /var/www/html/yum.

    # mkdir -p /var/www/html/yum
    Note

    The yum repository owner must have read and write permissions on this directory.

  4. If you created a base directory for the yum repository that is not under /var/www/html and SELinux is enabled in enforcing mode on your system:

    1. Use the semanage command to define the default file type of the repository root directory hierarchy as httpd_sys_content_t:

      # /usr/sbin/semanage fcontext -a -t httpd_sys_content_t "/var/yum(/.*)?"

    2. Use the restorecon command to apply the file type to the entire repository.

      # /sbin/restorecon -R -v /var/yum
  5. If you created a base directory for the yum repository that is not under /var/www/html, create a symbolic link in /var/www/html that points to the repository, for example:

    # ln -s /var/yum /var/www/html/yum
  6. Edit the HTTP server configuration file, /etc/httpd/conf/httpd.conf, as follows:

    1. Specify the resolvable domain name of the server in the argument to ServerName.

      ServerName server_addr:80

      If the server does not have a resolvable domain name, enter its IP address instead.

    2. Verify that the setting of the Options directive in the <Directory "/var/www/html"> section specifies Indexes and FollowSymLinks to allow you to browse the directory hierarchy, for example:

      Options Indexes FollowSymLinks
    3. Save your changes to the file.

  7. Start the HTTP server, and configure it to start after a reboot.

    # service httpd start
    # chkconfig httpd on
  8. If you have enabled a firewall on your system, configure it to allow incoming HTTP connection requests on TCP port 80.

    For example, the following command configures iptables to allow incoming HTTP connection requests and saves the change to the firewall configuration:

    # iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
    # service iptables save
  9. Install the uln-yum-mirror package:

    # yum install uln-yum-mirror

    This package contains the uln-yum-mirror script that enables the system to act as a local ULN mirror.

    Note

    If you have not subscribed the system to the correct Oracle Linux latest and addons channels for your system, the command fails with the error No package uln-yum-mirror available.

  10. To configure the operation of the /usr/bin/uln-yum-mirror script, edit the /etc/sysconfig/uln-yum-mirror file.

    For example, if the base directory for the yum repositories is not /var/www/html/yum, set the value of the REP_BASE parameter to the correct base directory:

    REP_BASE=/var/yum

    Installing the uln-yum-mirror package also configures an anacron job (/etc/cron.daily/uln-yum-mirror) that updates the local yum repositories once every day. You can disable this job by setting the value of CRON_ENABLED to 0:

    CRON_ENABLED=0

    For more information about the configuration options in /etc/sysconfig/uln-yum-mirror file, see Section 2.8.3, “ULN Mirror Configuration”.

    The repositories are populated when the anacron job runs the /usr/bin/uln-yum-mirror script. Alternatively, you can run the script manually at any time to update the repositories. See Section 2.8.4, “Updating the Repositories on a Local ULN Mirror”.

2.8.3 ULN Mirror Configuration

The /etc/sysconfig/uln-yum-mirror file contains the following configuration parameters that affect the behavior of the /usr/bin/uln-yum-mirror script:

ALL_PKGS

Specifies whether uln-yum-mirror mirrors all versions of every available package or downloads only the latest version of each package. The default value of 1 causes uln-yum-mirror to mirror all versions of every available package. A value of 0 causes uln-yum-mirror to download only the latest version of each package.

CRON_ENABLED

Specifies whether uln-yum-mirror runs automatically once per day. The default value of 1 enables uln-yum-mirror to be run automatically as an anacron job. A value of 0 disables the job. You must run uln-yum-mirror manually to update the packages.

HARDLINK_RPMS

Specifies whether uln-yum-mirror runs hardlinkpy to create hard links between identical RPMs after the mirror process finishes. The default value of 1 enables hard linking, which saves storage space. It is not possible to create hard links across file systems. Set the value to 0 if the repository storage spans more than one file system.

LOG_OUTPUT

Specifies whether uln-yum-mirror logs its output. The default value of 1 enables logging. A value of 0 disables logging.

REP_BASE

Specifies the base directory for the repositories. The default setting is /var/www/html/yum. Do not change this setting unless you customize the configuration of the HTTP server.

REP_EL, REP_ENG, REP_OL, REP_OVM, REP_UEK

Specify the names of the repositories. If required, you can configure alternate names.

REPO_FILE_DIR

Not currently used.

SRC

Specifies whether uln-yum-mirror mirrors source RPMs in addition to binary RPMs. The default value of 0 prevents uln-yum-mirror from mirroring source RPMs. A value to 1 causes uln-yum-mirror to mirror source RPMs.

YUM_GLOBAL_CACHE

Specifies the yum global cache directory. The default setting is /var/cache/yum. Do not change this setting unless you customize the configuration of the HTTP server.

2.8.4 Updating the Repositories on a Local ULN Mirror

To update the repositories for the subscribed channels immediately without waiting for the anacron job to run or if you have disabled the job, enter the following command on the local ULN mirror server:

# /usr/bin/uln-yum-mirror

Note

If you have not yet set up the contents of the repositories, it can take many hours to download all the packages.

2.8.5 Configuring yum on a Local ULN Mirror

The following procedure configures the yum command on a server that is acting as a local ULN mirror to install package updates from itself rather than from ULN. The procedure does not affect the operation of the uln-yum-mirror script.

To configure a server that is acting as a local ULN Mirror to be able to install updated packages from itself:

  1. Use the following command to list the channels that the server is mirroring 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_addons                Oracle Linux 6 Server Add ons (x86_64)       112
    ol6_x86_64_latest         Oracle Linux 6 Latest (x86_64)               17,976
    ol6_x86_64_UEKR3_latest   Latest Unbreakable Enterprise Kernel
                              Release 3 for Oracle Linux 6 (x86_64)        41

    In this example, the server mirrors the ol6_addons, ol6_x86_64_latest, and ol6_x86_64_UEKR3_latest channels from ULN.

  2. Edit /etc/yum/pluginconf.d/rhnplugin.conf and disable the mirrored channels by adding the following stanza for each channel:

    [repo_id]
    enabled=0

    For example, to disable the ol6_addons, ol6_x86_64_latest, and ol6_x86_64_UEKR3_latest channels, you would add the following stanzas:

    [ol6_addons]
    enabled=0
    
    [ol6_x86_64_latest]
    enabled=0
    
    [ol6_x86_64_UEKR3_latest]
    enabled=0
    Note

    If you subsequently subscribe the system to any additional channels on ULN, you must also disable those channels in /etc/yum/pluginconf.d/rhnplugin.conf.

  3. Configure the server as a yum client as described in Section 2.8.6, “Configuring Oracle Linux Yum Clients of a Local ULN Mirror”.

2.8.6 Configuring Oracle Linux Yum Clients of a Local ULN Mirror

If you have set up a local ULN mirror, you can configure your local Oracle Linux systems to receive yum updates from that server.

To configure an Oracle Linux system as a yum client:

  1. Import the GPG key:

    # rpm --import /usr/share/rhn/RPM-GPG_KEY
  2. In the /etc/yum.repos.d directory, edit the existing repository file, such as public-yum-ol6.repo or ULN-base.repo, and disable all entries by setting enabled=0.

  3. In the /etc/yum.repos.d directory, create the file local-yum.repo, which contains entries such as the following for an Oracle Linux 6 yum client:

    [local_ol6_latest]
    name=Oracle Linux $releasever - $basearch - latest
    baseurl=http://local_uln_mirror/yum/OracleLinux/OL6/latest/$basearch/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
    gpgcheck=1
    enabled=1
    
    [local_ol6_UEKR3_latest]
    name=Unbreakable Enterprise Kernel Release 3 for Oracle Linux $releasever - $basearch - latest
    baseurl=http://local_uln_mirror/yum/OracleLinux/OL6/UEKR3/latest/$basearch/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
    gpgcheck=1
    enabled=1
    
    [local_ol6_addons]
    name=Oracle Linux $releasever - $basearch - addons
    baseurl=http://local_uln_mirror/yum/OracleLinux/OL6/addons/$basearch/
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY
    gpgcheck=1
    enabled=1

    To distinguish the local repositories from the ULN repositories, prefix the names of their entries with a string such as local_.

    Replace local_uln_mirror with the IP address or resolvable host name of the local ULN mirror.

    The example configuration enables the local_ol6_latest, local_ol6_UEKR3_latest, and local_ol6_addons channels.

  4. To test the configuration:

    1. Clear the yum metadata cache:

      # yum clean metadata
    2. Use yum repolist to verify the configuration, for example:

      # 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_addons                Oracle Linux 6 - x86_64 - latest             112
      local_ol6_x86_64_latest         Oracle Linux 6 - x86_64 - latest             17,976
      local_ol6_x86_64_UEKR3_latest   Unbreakable Enterprise Kernel Release 3 
                                      for Oracle Linux 6 - x86_64 - latest         41

      If yum cannot connect to the local ULN mirror, check that the firewall settings on the local ULN mirror server allow incoming TCP connections to the HTTP port (usually, port 80).

  5. You can now run yum update to pick up new updates from the local ULN mirror.