Subscribing to Different Yum Repositories
Subscribe to different yum repositories in Oracle Linux.
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-eln
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.
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. |
The following listing shows an example repository section from a .repo
configuration file.
[ol10_appstream]
name=Oracle Linux $releasever Application Stream ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL10/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.
The following listing shows an example repository section from a .repo
configuration file.
[ol9_appstream]
name=Oracle Linux $releasever Application Stream ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL9/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.
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 (OCI) 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
OCI 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 in
Phoenix.
Typically, when you create an instance, this value is set to point to the closest regional
yum server on the OCI 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 config-manager
plugin is used to manage DNF
configuration and yum repositories.
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,
which can be used to edit and manage DNF configuration.
The following options are available:
- --add-repo url
-
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
- --enable repo_name
-
To enable a repository, use the
--enable
option. For example, to enable a repository named myrepo, run the following command:sudo dnf config-manager --enable myrepo
- --disable repo_name
-
To disable a repository, use the
--enable
option. For example, to disable a repository named myrepo, run the following command:sudo dnf config-manager --disable myrepo
- --setopt option=value
-
Use the
--setopt
option to set a configuration option to a specified value. For example, to disable GPG key validation on a repository named myrepo, run the following command:
Note that thesudo dnf config-manager --save --setopt=gpgcheck=0 myrepo
--save
option is often used with--setopt
, so that the value is saved to the configuration. - --save
-
Saves the current configuration.
- --dump
-
To view the current DNF configuration, use the
--dump
option to output the configuration to stdout.
See the dnf.plugin.config_manager(8)
manual page for more information.