11

I've installed CentOs 7 on my server and realized for some unknown reasons (at least by me), default yum repositories doesn't not work.

for example I tried yum install vim but got

Loaded plugins: fastestmirror

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=<repoid> ...

 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 <repoid>
    or
        subscription-manager repos --disable=<repoid>

 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=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: addons/7

I searched through the net to realize what's the problem and couldn't find anything. So I decided I should add the default repositories which should've been added by default myself.

But I couldn't find out how.

So is there a way to do that and make yum work?

The link which I've downloaded CentOs 7:

http://mirror.teklinks.com/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-Everything-1611.iso

EDIT 2

By cleaning all repositories and adding new ones from here considering my CentOS version the error is gone:

# yum clean all

# rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

# rpm -Uvh http://dl.atrpms.net/all/atrpms-repo-7-7.el7.x86_64.rpm

# rpm -Uvh http://repo.webtatic.com/yum/el7/webtatic-release.rpm

But now by running yum install vim I get:

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile
* epel: ftp.riken.jp
* remi-safe: rpms.remirepo.net
* webtatic: uk.repo.webtatic.com
No package vim available.
Error: Nothing to do

2
  • 1
    rpm -Uvh http://mirror.rackspace.com/CentOS/7/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm
    – jordanm
    Jun 12, 2017 at 7:32
  • Follw this link : digitalocean.com/community/questions/… RHEL-7 : In place of 6 ,put 7 in CentOS-Base.repo file.
    – kanth
    Jul 27, 2018 at 17:44

2 Answers 2

9

You neglected to add the default CentOS 7.x repos which is likely why you're running into your issue. Incidentally, you can fix this issue by grabbing yet another RPM:

$ rpm -ivh http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-6.1810.2.el7.centos.x86_64.rpm

NOTE: You can find out what RPM to acquire using rpm to query to see what RPM provides a given file. In our case these files:

$ rpm -qf /etc/yum.repos.d/CentOS-* | sort -u
centos-release-7-6.1810.2.el7.centos.x86_64

Once we re-install this RPM, it'll refresh our .repo files for the base repositories under /etc/yum.d. If we didn't know the URL where to download it, again, we can inquire to RPM to find out.

First take note of the name of the RPM:

$ rpm -qi centos-release-7-6.1810.2.el7.centos.x86_64 | grep Name
Name        : centos-release

Then search on pkgs.org for this shortname, which will lead you to the URL I showed above in the rpm -ivh ... command.

NOTE: The same steps can be applied for CentOS 7.3, or whatever version of CentOS you're currently using.

1

The files that configure the source of the repos are in

/etc/yum.conf
/etc/yum.repos.d/*

Verify that those files have the correct repo links. Specially the one in /etc/yum/repos.d

You may need sudo access to edit them. They are the equivalent of /etc/apt/sources.list of debian based systems

3
  • Thank you. But how can I make sure if they are correct links?
    – Ghasem
    Jun 12, 2017 at 10:39
  • 3
    See this related how do I install the stock centos repositories? Jun 12, 2017 at 13:33
  • I've copied the text from the link you suggested to Centos-Base.repo in /etc/yum/repos.d/ and /etc/yum.repos.d/*. I'm getting this error Could not retrieve mirrorlist error was 14: curl#56 - “Recv failure: Connection reset by peer” and posted a new question here I appreciate if you take a look at it
    – Ghasem
    Jun 13, 2017 at 7:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .