2 Configuring a System to Use Oracle Linux Yum Server

Define global configuration options in the dnf.conf file. Then edit, or create .repo files to define which repositories to subscribe to.

Configuring the Global DNF Configuration Settings

Edit the main configuration in /etc/dnf/dnf.conf. The global definitions for DNF are located under the [main] section heading of the DNF configuration file. The following table lists important directive for DNF.

Note:

For backward-compatibility purposes, a symbolic link to /etc/dnf/dnf.conf is created at /etc/yum.conf. The configuration syntax is the same; although, some configuration options have been deprecated and some new configuration options have been added. See Comparing Yum Version 3 With DNF for a list of the differences between configuration options and syntax.

See the dnf.conf(5) manual page for more information.

Directive Description
cachedir Directory used to store downloaded packages.
debuglevel Logging level, from 0 (none) to 10 (all).
exclude A space separated list of packages to exclude from installs or updates, for example: exclude=VirtualBox-4.? kernel*.
gpgcheck If set to 1, verify the authenticity of the packages by checking the GPG signatures. You might need to set gpgcheck to 0 if a package is unsigned, but be wary that the package could have been maliciously altered.
gpgkey Path to the GPG public key file.
installonly_limit Maximum number of versions that can be installed of any one package.
keepcache If set to 0, remove packages after installation.
logfile Path to the dnf log file.
obsoletes If set to 1, replace obsolete packages during upgrades.
plugins If set to 1, enable plugins that extend the functionality of dnf.
proxy URL of a proxy server including the port number. See Configuring a System to Use a Proxy With a Yum Server
proxy_password Password for authentication with a proxy server.
proxy_username Username for authentication with a proxy server.
reposdir Directories where dnf looks for repository files with a .repo extension. The default directory is /etc/yum.repos.d. See Subscribing to Different Yum Repositories.

Example [main] Configuration

The following listing shows an example [main] section from the DNF configuration file.

[main]
cachedir=/var/cache/dnf
keepcache=0
debuglevel=2
logfile=/var/log/dnf.log
obsoletes=1
gpgkey=file://media/RPM-GPG-KEY
gpgcheck=1
plugins=1
installonly_limit=3

Configuring a System to Use a Proxy With a Yum Server

If the organization uses a proxy server as an intermediary for internet access, specify the proxy setting in /etc/dnf/dnf.conf as shown in the following example.

proxy=http://proxysvr.example.com:3128

If the proxy server requires authentication, also specify the proxy_username, and proxy_password settings.

proxy=http://proxysvr.example.com:3128
proxy_username=user
proxy_password=password              

Caution:

All dnf users require read access to /etc/dnf/dnf.conf or /etc/sysconfig/rhn/up2date. If these files must be world-readable, don't use a proxy password that's the same as any user's login password, and especially not root's password.

Configuring Access to the Oracle Linux Yum Server Through a Firewall

The Oracle Linux yum server delivers content through a Content Delivery Network (CDN). When you connect to the Oracle Linux yum server, you connect to a node on the CDN that's geographically closer to the system you're using. With CDN, download speeds are faster.

Because the CDN has many nodes that run on different networks around the world, you can not configure any single IP address or network range for an egress firewall rule.

In environments where a strict firewall policy limits outbound connections for systems, we recommend configuring a local yum mirror server within a demilitarized zone (DMZ). See Setting Up a Local Yum Mirror for information on how to configure a local yum mirror.

Subscribing to Different Yum Repositories

Oracle Linux uses modular yum repository configuration files that are made available as release packages that are maintained through yum. Release packages simplify repository management and also ensures that yum repository definitions are kept up-to-date automatically whenever you update the system.

On all Oracle Linux systems, the oraclelinux-release-el8 package is installed by default. This package contains the core repository configurations to access all the repositories required for an Oracle Linux system to install common OS software packages and the other release packages used to obtain other yum repository configurations.

A list of all available RPM files to manage all the possible yum repository configurations for a release can be obtained by running the following command, where n is the Oracle Linux release version of the RPM files, such as -el8.

dnf list "*release-eln*"

To install the yum repository configuration for a particular set of software, use the dnf command to install the corresponding package.

Editing Yum Repository Configuration Files

DNF uses yum repository configuration files to configure where to install different packages and their dependencies from. By default, repository configuration files are stored in the /etc/yum.repos.d directory. You can define another directory location to store repository configurations by setting the reposdir directive in the dnf.conf file.

Use the repository directory to define .repo files for repositories that you want to make available. A .repo file can contain entries for more than one yum repository. To subscribe to a repository, you can edit the enabled option to a value of 1 and save the configuration file. The change has immediate effect.

The following table describes the basic directives for a repository. Any other directive that appears in the repository file override the corresponding global definition in the [main] section of the DNF configuration file. See the dnf.conf(5) manual page for more information.

Directive Description
baseurl Location of the repository (expressed as a file://, ftp://, http://, or https:// address). This directive must be specified.
enabled Whether to enable dnf to use the repository. Set the value to 1 to enable the repository, or 0 to disable the repository.
name Descriptive name for the repository channel. This directive must be specified.

Example Repository Listing

The following listing shows an example repository section from a .repo configuration file.

[ol8_appstream]
name=Oracle Linux $releasever Application Stream ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL8/appstream/$basearch
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1

In this example, the values of gpgkey and gpgcheck override any global setting. dnf substitutes the name of the current system's architecture for the variable $basearch.

Configure Compute Instances Access to Regional Yum Server Repositories

Compute instances in Oracle Cloud Infrastructure have access to regional yum servers through the service gateway. The base URL of the repository uses the $ociregion variable to define which regional server to use and the $ocidomain variable to define the domain where the yum server is located. By using variables, configuration can remain relatively standard across Oracle Linux deployments but provide access to extra resources available to Oracle Cloud Infrastructure customers.

For example, the base URL to the ol8_baseos_latest repository for Oracle Linux 8 is:

baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL8/baseos/latest/$basearch

You can set the $ociregion variable by populating content in /etc/dnf/vars/ociregion. For example, if $ociregion is set to -phx, the base URL expands to point to the regional yum server located in Phoenix.

Typically, when you create an instance, this value is set to point to the closest regional yum server on the Oracle Cloud Infrastructure service network. If the /etc/dnf/vars/ociregion file doesn't exist, or the file is empty, the base URL points to the publicly accessible Oracle Linux yum server.

Using the DNF config-manager Plugin

The dnf-plugins-core package includes several utilities that can help you to manage configuration and safely apply updates to existing configuration. The most significant of these utilities is the dnf config-manager plugin.

You can use dnf config-manager to add repositories, either at a specified URL or within a specified repository file. For example, to add a repository configuration file for Oracle Linux that's hosted on a remote server, you can run the following command:

sudo dnf config-manager --add-repo https://example.com/my_yum_config.repo

You can use the same command to automatically generate a repository configuration file for a valid yum repository by pointing to the URL of which the repository is hosted. For example, to create a configuration file in /etc/repos.d for an example repository, run the following command:

sudo dnf config-manager --add-repo https://example.com/repo/el-release/myrepo/x86_64

To enable a repository by using dnf config-manager, use the --enable option. For example, to enable a repository named myrepo, run the following command:

sudo dnf config-manager --enable myrepo

You can use the --disable option in a similar way to disable a repository.

You can also use the dnf config-manager tool to set other configuration options by specifying the --setopt and --save options. See the dnf.plugin.config_manager(8) manual page for more information.

How to Recover the Base Yum Repository Configuration

Perform this task if the system's base repository configuration has been corrupted or otherwise lost.
  1. Create a temporary repository configuration file in /etc/yum.repos.d.
    sudo mkdir /etc/yum.repos.d/temp_base.repo
  2. Populate the file with entries corresponding to the system's OS version.
    • For Oracle Linux 9:

      [ol9_baseos_latest]
      name=Oracle Linux 9 BaseOS Latest ($basearch)
      baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL9/baseos/latest/$basearch/
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      gpgcheck=1
      enabled=1
    • For Oracle Linux 8:

      [ol8_baseos_latest]
      name=Oracle Linux 8 BaseOS Latest ($basearch)
      baseurl=https://yum$ociregion.$ocidomain/repo/OracleLinux/OL8/baseos/latest/$basearch/
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
      gpgcheck=1
      enabled=1
  3. Reinstall the required release packages of the system's OS version to set up the standard yum repository configurations.
    sudo dnf reinstall oraclelinux-release-olrelease-nbr
  4. Verify that the recovery is successful.
    ls /etc/yum.repos.d/oraclelinux-release-olrelease-nbr
  5. Remove the temporary configuration file.
    rm /etc/yum.repos.d/temporary_base.repo
  6. Reinstall other required release packages to obtain the correct repository configurations.
    sudo dnf reinstall repository
  7. Enable the repositories that you need.
    sudo dnf config-manager --enable repository