Bobcares

AWS yum repository – Easy way to set up and fix errors

by | Jul 21, 2019

AWS Yum repository makes software package management easy.

These repositories provide a single source of updates and avoid numerous copies of software applications.

Amazon users can make use of Amazon repositories to install different software packages. However, for specific packages, it may require a custom YUM repository.

That’s why we regularly receive requests to create an AWS Yum repository as part of our Server Management Services.

In this write-up, we’ll see how our Support Engineers create a yum repository in AWS server and fix related errors.

 

How we add repositories in Amazon Linux

Amazon Linux has two repositories by default, namely amzn-main and amzn-updates. As we already saw, to install specific packages, Amazon instance need custom Yum repository set up.

Here, we begin with adding the repository information to the /etc/yum.conf file or to its own repository.repo file in the /etc/yum.repos.d directory.

To add a yum repository to /etc/yum.repos.d, our Support Engineers follow the below steps.

1. Initially, we find the location of the .repo file. Again, depending on the repository you add, the location will differ.

For example,

https://www.domain.com/example.repo.

2. Next, we add the repository by using yum-config-manager command.

yum-config-manager --add-repo https://www.domain.com/example.repo

3. After that, we enable a yum repository in /etc/yum.repos.d with the following command.

yum-config-manager --enable epel

In addition, we use a command  yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm , to enable the EPEL repository on Amazon Linux 2.

That’s it, we have successfully added a yum repository on Amazon Linux.

However, we always ensure to enable only an authenticated repository to avoid security breaches on the server.

 

How we fixed common errors with Yum repository

From our experience in managing servers, we’ve seen customers facing problems after adding a new repository or while using it. Now, let’s check on how our Support Engineers resolve errors related to the AWS repository​.

 

1. Bad public DNS Settings

Recently, one of our customers reported that his Yum command did not work after creating a new yum repository on his AWS server. While installing a package, he got an error like,

Loaded plugins: priorities, update-motd, upgrade-helper
Could not retrieve mirrorlist http://repo.us-east-1.amazonaws.com/latest/main/mirror.list error was
12: Timeout on http://repo.us-east-1.amazonaws.com/latest/main/mirror.list: (28, 'Connection timed out after 10001 milliseconds')
One of the configured repositories failed (Unknown)

Then, our Support Engineers found this error caused due to bad public DNS settings of the EC2 instance.

Therefore, we solved this error by properly updating the public DNS as follows.

  1. We logged in to console.aws.amazon.com and selected Services > VPC
  2. Then, we selected the VPC connected to the EC2
  3. At last, we clicked Edit option > Change DNS hostnames to YES

 

That enabled the DNS hostname and the problem was solved.

 

2. Blocked traffic

Similarly, another customer got an error while running command yum install httpd. The error looked like as follow.

Loaded plugins: priorities, update-motd, upgrade-helper
http://packages.us-west-1.amazonaws.com/2013.09/main/201309001984/x86_64/repodata/repomd.xml?instance_id=i-923d2fc9&region=us-west-1: Errno 12 Timeout on http://packages.us-west-1.amazonaws.com/2013.09/main/201309001984/x86_64/repodata/repomd.xml?instance_id=i-923d2fc9&region=us-west-1: (28, 'Connection timed out after 10161 milliseconds')
Trying other mirror.

Error downloading packages:
generic-logos-17.0.0-2.5.amzn1.noarch: failure: Packages/generic-logos-17.0.0-2.5.amzn1.noarch.rpm from amzn-main: Errno 256 No more mirrors to try.

On checking, our Support Engineers found that the problem was with network ACL.

Also, he had a network ACL setup for the custom VPC subnet that blocked all inbound and outbound HTTP/ HTTPS traffic.

Therefore, we allowed HTTP and HTTPS traffic on the ACL network for the subnet that the instance sits in.

This fixed the problem and the installation of packages via Yum worked fine.

 

[Do you get trouble while creating AWS yum repository? Our AWS Experts can fix it for you.]

 

Conclusion

In a nutshell, users may face errors while creating an AWS yum repository, because of bad public DNS settings of an EC2 instance or incorrect ACL, network settings. Today, we saw how our Support Engineers set up YUM repository and fix related errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

6 Comments

  1. Szczepan Hołyszewski

    This is outdated. “yum-config-manager” binary is no longer available on EC2 instances as of 2020, and it is not in the enabled repositories either.

    Reply
    • Sijin George

      Hello,
      yum-config-manager does work in EC2 instances. Successfully added a repo in Amazon Linux release 2 (Karoo) based instance.

      Reply
  2. Anil Samuel

    I have the error below in Amzn Linux2 running in WSL2.

    -bash-4.2# yum update -y
    Loaded plugins: ovl, priorities
    Could not retrieve mirrorlist http://amazonlinux.default.amazonaws.com/2/core/latest/x86_64/mirror.list error was
    12: Timeout on http://amazonlinux.default.amazonaws.com/2/core/latest/x86_64/mirror.list: (28, ‘Resolving timed out after 5000 milliseconds’)

    One of the configured repositories failed (Unknown),
    and yum doesn’t have enough cached data to continue. At this point the only
    safe thing yum can do is fail. There are a few ways to work “fix” this:

    1. Contact the upstream for the repository and get them to fix the problem.

    2. Reconfigure the baseurl/etc. for the repository, to point to a working
    upstream. This is most often useful if you are using a newer
    distribution release than is supported by the repository (and the
    packages for the previous distribution release still work).

    3. Run the command with the repository temporarily disabled
    yum –disablerepo= …

    4. Disable the repository permanently, so yum won’t use it by default. Yum
    will then just ignore the repository until you permanently enable it
    again or use –enablerepo for temporary usage:

    yum-config-manager –disable
    or
    subscription-manager repos –disable=

    5. Configure the failing repository to be skipped, if it is unavailable.
    Note that yum will try to contact the repo. when it runs most commands,
    so will have to try and fail each time (and thus. yum will be be much
    slower). If it is a very temporary problem though, this is often a nice
    compromise:

    yum-config-manager –save –setopt=.skip_if_unavailable=true

    Cannot find a valid baseurl for repo: amzn2-core/2/x86_64

    But the URL seem to work when tested using cURL.

    -bash-4.2# curl http://amazonlinux.default.amazonaws.com/2/core/latest/x86_64/mirror.list
    https://cdn.amazonlinux.com/2/core/2.0/x86_64/c5be7c72d2e91748f8bef8134260b625b2675db49524daec66d65baf81eb4046

    Reply
    • Hiba Razak

      Hi,

      Our Experts can help you with the issue, we’ll be happy to talk to you on chat

      Reply
    • Ranjan Kumar

      Anil Samuel – could you please confirm how you resolved this issue. I am getting the same error.

      Reply
      • Hiba Razak

        Hello Ranjan,
        Our Experts can help you with the issue, we’ll be happy to talk to you on chat(click on the icon at right-bottom).

        Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.