2 Yum Configuration
The main configuration file for yum is
/etc/yum.conf
. This chapter describes how to
configure directives in the configuration file.
Yum Configuration Directives
The global definitions for yum are located under the
[main]
section heading of the yum
configuration file. The following table lists the important
directives.
Directive | Description |
---|---|
|
Directory used to store downloaded packages. |
|
Logging level, from 0 (none) to 10 (all). |
|
If set to 1, only update packages for the correct architecture. |
|
A space separated list of packages to exclude from
installs or updates, for example:
|
|
If set to 1, verify the authenticity of the packages
by checking the GPG signatures. You might need to set
|
|
Pathname of the GPG public key file. |
|
Maximum number of versions that can be installed of any one package. |
|
If set to 0, remove packages after installation. |
|
Pathname of the yum log file. |
|
If set to 1, replace obsolete packages during upgrades. |
|
If set to 1, enable plugins that extend the functionality of yum. |
|
URL of a proxy server including the port number. See Configuring Use of a Proxy Server. |
|
Password for authentication with a proxy server. |
|
User name for authentication with a proxy server. |
|
Directories where yum should look
for repository files with a |
See the yum.conf(5)
manual page for more
information.
The following listing shows an example [main]
section from the yum configuration file.
[main] cachedir=/var/cache/yum keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgkey=file://media/RPM-GPG-KEY gpgcheck=1 pligins=1 installonly_limit=3
It is possible to define repositories below the [main] section
in /etc/yum.conf
or in separate repository
configuration files. By default, yum expects
any repository configuration files to be located in the
/etc/yum.repos.d
directory unless you use the
reposdir
directive to define alternate
directories.
Configuring Use of a Proxy Server
If your organization uses a proxy server as an intermediary for
Internet access, specify the proxy
setting in
/etc/yum.conf
as shown in the following
example.
proxy=http://proxysvr.example.com:3128
If the proxy server requires authentication, additionally
specify the proxy_username
, and
proxy_password
settings.
proxy=http://proxysvr.example.com:3128 proxy_username=yumacc proxy_password=clydenw
If you use the yum plugin (yum-rhn-plugin
) to
access the ULN, specify the enableProxy
and
httpProxy
settings in
/etc/sysconfig/rhn/up2date
as shown in this
example.
enableProxy=1 httpProxy=http://proxysvr.example.com:3128
If the proxy server requires authentication, additionally
specify the enableProxyAuth
,
proxyUser
, and
proxyPassword
settings.
enableProxy=1 httpProxy=http://proxysvr.example.com:3128 enableProxyAuth=1 proxyUser=yumacc proxyPassword=clydenw
Caution:
All yum users require read access to
/etc/yum.conf
or
/etc/sysconfig/rhn/up2date
. If these files
must be world-readable, do not use a proxy password that is
the same as any user's login password, and especially not
root
's password.
Yum Repository Configuration
The yum configuration file or yum repository configuration files can contain one or more sections that define repositories.
The following table lists the basic directives for a repository.
Directive | Description |
---|---|
|
Location of the repository channel (expressed as a
|
|
If set to 1, permit yum to use the channel. |
|
Descriptive name for the repository channel. This directive must be specified. |
Any other directive that appears in this section overrides the
corresponding global definition in [main]
section of the yum configuration file. See the
yum.conf(5)
manual page for more information.
The following listing shows an example repository section from a configuration file.
[ol6_u2_base] name=Oracle Linux 6 U2 - $basearch - base baseurl=https://yum.oracle.com/repo/OracleLinux/OL6/2/base/$basearch gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY gpgcheck=1 enabled=1
In this example, the values of gpgkey
and
gpgcheck
override any global setting.
yum substitutes the name of the current
system's architecture for the variable
$basearch.
yum automatically searches the
/etc/yum.repos.d
directory for files with the
suffix .repo
and appends these to the
configuration when it is processing. Use this directory to
define repository files for repositories that you want to make
available.
Downloading the Oracle Linux Yum Server Repository Files
The Oracle Linux yum server provides a direct mapping of all of the Unbreakable Linux Network (ULN) channels that are available to the public without any specific support agreement. The repository labels used for each repository on the Oracle Linux yum server map directly onto the channel names on ULN. See Oracle Linux: Unbreakable Linux Network User's Guide for Oracle Linux 6 and Oracle Linux 7 at https://docs.oracle.com/en/operating-systems/oracle-linux/uln-user/ol_channels_uln.html for more information about the channel names and common suffixes used for channels and repositories.
Prior to January 2019, Oracle shipped a single yum repository
configuration file for each Oracle Linux release. This configuration
file is copied into
/etc/yum.repos.d/public-yum-ol7.repo
at
installation, but can also be downloaded from the Oracle Linux yum server directly
to obtain updates.
The original configuration file is deprecated in favor of
modular repository files that are managed and updated
automatically via yum in the form of RPM packages that are more
targeted in scope. For example, core repository configuration
files required for Oracle Linux 7 are available in the
oraclelinux-release-el7
package. This package
includes all of the repository configuration required to install
base packages for the release, including packages from the
ol7_latest
, ol7_addons
repositories and all of the supported repositories for UEK.
The modular yum repository configuration files released as packages that can be maintained via yum can help to simplify repository management and also ensure that your yum repository definitions are kept up to date automatically, whenever you update your system.
A list of all available RPM files to manage all of the possible yum repository configurations for your release can be obtained by running:
sudo yum list *release-el7*
To install the yum repository configuration for a particular set of software that you wish to use, use yum to install the corresponding package. For example, to install the yum repository configuration for the Oracle Linux Software Collection Library, run:
sudo yum install oracle-softwarecollection-release-el7If your system is still configured to use the original single yum repository configuration file at
/etc/yum.repos.d/public-yum-ol7.repo
, you should update your system to
transition to the current approach to handling yum repository configuration. To do this,
ensure that your system is up to date and then run the
/usr/bin/ol_yum_configure.sh
script:
sudo yum update sudo /usr/bin/ol_yum_configure.sh
The /usr/bin/ol_yum_configure.sh
script
checks the
/etc/yum.repos.d/public-yum-ol7.repo
file to
determine which repositories are already enabled and installs
the appropriate corresponding packages before renaming the
original configuration file to
/etc/yum.repos.d/public-yum-ol7.repo.sav
to
disable it in favor of the more recent modular repository
configuration files.
If, for some reason, you manage to remove all configuration to
access the Oracle Linux yum server repositories, you should create a temporary yum
repository configuration file at
/etc/yum.repos.d/ol7-temp.repo
with the
following as the minimum required content:
[ol7_latest] name=Oracle Linux $releasever Latest ($basearch) baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/latest/$basearch/ gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle gpgcheck=1 enabled=1
Then reinstall the oraclelinux-release-el7
package to restore the default yum configuration:
sudo yum reinstall oraclelinux-release-el7 sudo rm /etc/yum.repos.d/ol7-temp.repo
For more information on manually setting up Oracle Linux yum server repository configuration files, see https://yum.oracle.com/getting-started.html.
You can enable or disable repositories in each repository
configuration file by setting the value of the
enabled
directive to 1 or 0 for each
repository listed in the file, as required. The preferred method
of enabling or disabling repositories under Oracle Linux 7 is to use the
yum-config-manager command as described in
Using Yum Utilities to Manage Configuration.
Using Yum on Oracle Cloud Infrastructure Systems
Compute instances in Oracle Cloud Infrastructure have access to regional yum servers via the service gateway. Regional yum servers on Oracle Cloud Infrastructure differ from the Oracle Linux yum server in that they also mirror content available on restricted ULN channels.
Yum repository configuration in Oracle Linux typically makes use of a
yum variable in the baseurl for managing appropriate yum server
access. For example, the baseurl to the
_latest
repository for Oracle Linux 7 is:
baseurl=https://yum$ociregion.oracle.com/repo/OracleLinux/OL7/latest/$basearch/
The $ociregion
variable can be set by
populating content in
/etc/yum/vars/ociregion
. If this file does
not exist, or the file is empty, the baseurl is expanded to
point to the publicly accessible Oracle Linux yum server. In the case of a typical
Oracle Cloud Infrastructure compute instance, the value of
variable is set when the instance is created so that the baseurl
is expanded to point to the closest regional yum server on the
Oracle Cloud Infrastructure service network. For example, if
$ociregion
is set to -phx
,
the baseurl expands to point to the regional yum server located
in Phoenix.
By using variables, configuration can remain relatively standard across Oracle Linux deployments but provide access to the additional resources available to Oracle Cloud Infrastructure customers.
For more information on Oracle Cloud Infrastructure and yum repositories, see See Oracle Linux: Unbreakable Linux Network User's Guide for Oracle Linux 6 and Oracle Linux 7.
Using Yum Utilities to Manage Configuration
The yum-utils
package includes several
utilities that can help you to manage configuration and apply
updates safely to your existing configuration. Most significant
of these is yum-config-manager.
To install the yum-utils
package:
sudo yum install -y yum-utils
You can use yum-config-manager to add repositories either at a specified URL, or within a specified repository file. For example, to add the legacy repository configuration file for Oracle Linux 7 from the Oracle Linux yum server:
sudo yum-config-manager --add-repo https://yum.oracle.com/public-yum-ol7.repo
Note:
The legacy repository configuration file is unmaintained and deprecated. The information in this file may not be current and newer repositories may not be listed.
You can use the same command to automatically generate a
repository configuration file for a valid yum repository, by
pointing to the URL where the repository is hosted. For example,
to create a new configuration file in
/etc/repos.d
for the Unbreakable Enterprise Kernel Release 5 repository. run:
sudo yum-config-manager --add-repo https://yum.oracle.com/repo/OracleLinux/OL7/UEKR5/x86_64
To enable a repository using
yum-config-manager, use the
--enable
option. For example, to enable the
ol7_addons
repository, run:
# yum-config-manager --enable ol7_addons
You can use the --disable
option in a similar
way to disable a repository.
The yum-config-manager tool can also be used
to set other configuration options using the
--setopt
and --save
options. See the yum-config-manager(1)
manual
page for more information.
For a list of the tools included in the yum-utils package and a
description of what these tools can do, see the
yum-utils(1)
manual page for more
information.