Добавить репозиторий red hat linux

Chapter 10. Managing custom software repositories

You can configure a repository in the /etc/dnf/dnf.conf file or in a .repo file in the /etc/yum.repos.d/ directory.

The configuration information for DNF and related utilities are stored in the /etc/dnf/dnf.conf file. This file contains the [main] section and can contain one or more [repository] sections, which allow you to set repository-specific options. The values you define in individual [repository] sections of the /etc/dnf/dnf.conf file override values set in the [main] section.

However, it is recommended to define individual repositories in new or existing .repo files in the /etc/yum.repos.d/ directory.

In the following sections, learn how to manage custom software repositories by using DNF :

10.1. Setting DNF repository options

The /etc/dnf/dnf.conf configuration file contains the [ repository ] sections, where repository is a unique repository ID. The [ repository ] sections allow you to define individual DNF repositories.

Do not give custom repositories names used by the Red Hat repositories to avoid conflicts.

For a complete list of available [ repository ] options, see the [ repository ] OPTIONS section of the dnf.conf(5) man page.

10.2. Adding a DNF repository

To define a new repository, you can either:

  • Add a [ repository ] section to the /etc/dnf/dnf.conf file.
  • Add a [ repository ] section to a .repo file in the /etc/yum.repos.d/ directory. Installed RPMs or software management tools, for example, Subscription Manager, can provide their own .repo file.

Define your repositories in a .repo file instead of /etc/dnf/dnf.conf because all files with the .repo file extension in this directory are read by dnf .

To add a DNF repository to your system by using the dnf config-manager command, complete the following steps.

    Add a repository to your system:

# dnf config-manager --add-repo repository_URL

Obtaining and installing software packages from unverified or untrusted sources other than Red Hat certificate-based Content Delivery Network ( CDN ) is a potential security risk, and can lead to security, stability, compatibility, and maintainability issues.

10.3. Enabling a DNF repository

To enable a DNF repository added to your system by using the dnf config-manager command, complete the following steps.

# dnf config-manager --enable repositoryID

Additional resources

Читайте также:  Linux mint проверить обновления

10.4. Disabling a DNF repository

To disable a DNF repository added to your system by using the dnf config-manager command, complete the following steps.

# dnf config-manager --disable repositoryID

Additional resources

Источник

How to add a Yum repository

There are a few different ways to add a Yum repository to your system, depending on what you need from the repository. Let’s look at three different options.

Yum respositories represented by clay pots of various shapes and sizes

In most scenarios, when you build out a new system, you want to keep the installation footprint as small as possible. As a result, not all repositories and packages are typically installed at that time. Fortunately, repositories can be enabled and disabled through yum at any time, and there are many different sources you can choose from.

In this example, we’ll look specifically at Fedora, but the process is similar across other distributions utilizing yum .

Great Linux resources

It is always recommended you use a known repository, such as Extra Packages for Enterprise Linux (EPEL), which is hosted at fedoraproject.org. Or, you might need a specific version of MySQL, which is hosted at mysql.com. There are also circumstances where you might need to add a lesser-known repository, such as remirepo.net for versions of PHP, or even host your own repository.

Once you determine which repository you need, there are several different ways to install and enable it.

Install a repository .rpm

The first is to install an .rpm with the repository information. The following command installs the EPEL repository for CentOS 8:

# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm 

Set up only a section of a repository

In the case of needing a specific repository, as in the case of PHP 7.2, you first need to install the repo and then disable and enable repositories using yum-config-manager as follows:

$ sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm $ sudo yum-config-manager --disable remi-php54 $ sudo yum-config-manager --enable remi-php72 

Manually set up a repository

The last method of configuring a yum repository manually, where we create a .repo file within /etc/yum.repo.d using a text editor. In this example, we will create the repository file for MySQL 5.7:

$ nano /etc/yum.repo.d/mysql57-community.repo [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 

Now, let’s discuss the lines we configured. The first three lines contain the minimum information you need when creating a .repo file. The first line is the unique identifier for the section and is enclosed in [] :

Читайте также:  Как в линуксе поменять время

Note: You can have more than section (repository) in a .repo file.

The second line in our file is the name we choose to describe the repository:

name=MySQL 5.7 Community Server 

The third line is the location ( baseurl ) of the repository. In this case, we are using HTTP to access it:

baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ 

As we mentioned, the first three lines are mandatory to configure a repository. We have also configured three more options. In the first additional option, we configured the toggle enabled , where 0 is disabled and 1 is enabled:

In the last two lines, we configured our information related to GPG. The first of these lines is the toggle to check for GPG and the second is the location of the key you are checking against:

gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 

To see a complete list of repository options, see the man page as follows:

Now that you have your new repository configured using one of these methods, you should verify that it is configured properly using the yum-config-manager command from earlier to enable and disable PHP sections:

# yum-config-manager mysql57-community 

This command returns the complete information for the repository:

[root@centos3 yum.repos.d]# yum-config-manager mysql57-community Loaded plugins: fastestmirror ================================================================================================= repo: mysql57-community ================================================================================================== [mysql57-community] async = True bandwidth = 0 base_persistdir = /var/lib/yum/repos/x86_64/7 baseurl = http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/ cache = 0 cachedir = /var/cache/yum/x86_64/7/mysql57-community check_config_file_age = True compare_providers_priority = 80 cost = 1000 deltarpm_metadata_percentage = 100 deltarpm_percentage = enabled = True enablegroups = True exclude = failovermethod = priority ftp_disable_epsv = False gpgcadir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgcadir gpgcakey = gpgcheck = True gpgdir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgdir gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql hdrdir = /var/cache/yum/x86_64/7/mysql57-community/headers http_caching = all includepkgs = ip_resolve = keepalive = True keepcache = False mddownloadpolicy = sqlite mdpolicy = group:small mediaid = metadata_expire = 21600 metadata_expire_filter = read-only:present metalink = minrate = 0 mirrorlist = mirrorlist_expire = 86400 name = MySQL 5.7 Community Server old_base_cache_dir = password = persistdir = /var/lib/yum/repos/x86_64/7/mysql57-community pkgdir = /var/cache/yum/x86_64/7/mysql57-community/packages proxy = False proxy_dict = proxy_password = proxy_username = repo_gpgcheck = False retries = 10 skip_if_unavailable = False ssl_check_cert_permissions = True sslcacert = sslclientcert = sslclientkey = sslverify = True throttle = 0 timeout = 30.0 ui_id = mysql57-community/x86_64 ui_repoid_vars = releasever, basearch username = 

With your repository installed, you are ready to use yum to install the packages located there!

[ Want to try out Red Hat Enterprise Linux? Download it now for free. ]

Источник

8.4.5. Adding, Enabling, and Disabling a Yum Repository

Section 8.4.2, “Setting [repository] Options” described various options you can use to define a Yum repository. This section explains how to add, enable, and disable a repository by using the yum-config-manager command.

Читайте также:  Epson l805 linux драйвер

When the system is registered with the certificate-based Red Hat Network , the Red Hat Subscription Manager tools are used to manage repositories in the /etc/yum.repos.d/redhat.repo file. See Chapter 6, Registering the System and Managing Subscriptions for more information how to register a system with Red Hat Network and use the Red Hat Subscription Manager tools to manage subscriptions.

Adding a Yum Repository

To define a new repository, you can either add a [repository] section to the /etc/yum.conf file, or to a .repo file in the /etc/yum.repos.d/ directory. All files with the .repo file extension in this directory are read by yum , and it is recommended to define your repositories here instead of in /etc/yum.conf .

Obtaining and installing software packages from unverified or untrusted software sources other than Red Hat Network constitutes a potential security risk, and could lead to security, stability, compatibility, and maintainability issues.

Yum repositories commonly provide their own .repo file. To add such a repository to your system and enable it, run the following command as root :

yum-config-manager --add-repo repository_url

where repository_url is a link to the .repo file. For example, to add a repository located at http://www.example.com/example.repo, type the following at a shell prompt:

~]# yum-config-manager --add-repo http://www.example.com/example.repo Loaded plugins: product-id, refresh-packagekit, subscription-manager adding repo from: http://www.example.com/example.repo grabbing file http://www.example.com/example.repo to /etc/yum.repos.d/example.repo example.repo | 413 B 00:00 repo saved to /etc/yum.repos.d/example.repo

Enabling a Yum Repository

yum-config-manager --enable repository

where repository is the unique repository ID (use yum repolist all to list available repository IDs). Alternatively, you can use a glob expression to enable all matching repositories:

yum-config-manager --enable glob_expression

For example, to enable repositories defined in the [example] , [example-debuginfo] , and [example-source] sections, type:

~]# yum-config-manager --enable example\* Loaded plugins: product-id, refresh-packagekit, subscription-manager ============================== repo: example ============================== [example] bandwidth = 0 base_persistdir = /var/lib/yum/repos/x86_64/6Server baseurl = http://www.example.com/repo/6Server/x86_64/ cache = 0 cachedir = /var/cache/yum/x86_64/6Server/example [output truncated]

When successful, the yum-config-manager —enable command displays the current repository configuration.

Disabling a Yum Repository

yum-config-manager --disable repository

where repository is the unique repository ID (use yum repolist all to list available repository IDs). Similarly to yum-config-manager —enable , you can use a glob expression to disable all matching repositories at the same time:

yum-config-manager --disable glob_expression

Источник

Оцените статью
Adblock
detector