others-How to solve yum update or yum install problem on centos servers?
1. Purpose
In this post, I would demo how to solve below exception or error when doing yum update
or yum install xxx
:
[[email protected] ~]# yum install mosh
you get this result:
perl-Socket6-0.23-4.el6.x86_64: Cannot find a valid baseurl for repo: base
perl-IO-Socket-INET6-2.56-4.el6.noarch: Cannot find a valid baseurl for repo: base
Or you try to use the yum update
, you still get the following errors:
perl-Git-1.7.1-10.el6_10.noarch: Cannot find a valid baseurl for repo: updates
sudo-1.8.6p3-29.el6_10.3.x86_64: Cannot find a valid baseurl for repo: updates
curl-7.19.7-54.el6_10.x86_64: Cannot find a valid baseurl for repo: updates
freetype-2.3.11-19.el6_10.x86_64: Cannot find a valid baseurl for repo: updates
And I have tried to enable the baseurl in the /etc/yum.repos.d/CentOS-Base.repo, but it’s still not working.
2. Environment
- centos 6
3. The solution
From November 30, 2020, the major open source mirror sites of centos6 have been discontinued for maintenance, but Alibaba source can still be used because of the previous version of centos packages in his centos-vault warehouse.
Just execute this command on your server, it would set
sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo
yum clean all
yum makecache
Now try again:
[[email protected] ~]# yum install mosh
We get this:
Installed:
mosh.x86_64 0:1.3.2-1.el6
Installed as dependencies:
perl-IO-Socket-INET6.noarch 0:2.56-4.el6 perl-Socket-GetAddrInfo.x86_64 0:0.12-1.el6 perl-Socket6.x86_64 0:0.23-4.el6 protobuf.x86_64 0:2.3.0-9.el6
Complete!
4. The reason
In fact, we are using the below repo file:
File: Centos-6-Vault-Aliyun.repo
───────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ # CentOS-Base.repo
2 │ #
3 │ # The mirror system uses the connecting IP address of the client and the
4 │ # update status of each mirror to pick mirrors that are updated to and
5 │ # geographically close to the client. You should use this for CentOS updates
6 │ # unless you are manually picking other mirrors.
7 │ #
8 │ # If the mirrorlist= does not work for you, as a fall back you can try the
9 │ # remarked out baseurl= line instead.
10 │ #
11 │ #
12 │
13 │ [base]
14 │ name=CentOS-6.10 - Base - mirrors.aliyun.com
15 │ failovermethod=priority
16 │ baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
17 │ gpgcheck=1
18 │ gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
19 │
20 │ #released updates
21 │ [updates]
22 │ name=CentOS-6.10 - Updates - mirrors.aliyun.com
23 │ failovermethod=priority
24 │ baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
25 │ gpgcheck=1
26 │ gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
27 │
28 │ #additional packages that may be useful
29 │ [extras]
30 │ name=CentOS-6.10 - Extras - mirrors.aliyun.com
31 │ failovermethod=priority
32 │ baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
33 │ gpgcheck=1
34 │ gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
35 │
36 │ #additional packages that extend functionality of existing packages
37 │ [centosplus]
38 │ name=CentOS-6.10 - Plus - mirrors.aliyun.com
39 │ failovermethod=priority
40 │ baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
41 │ gpgcheck=1
42 │ enabled=0
43 │ gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
44 │
45 │ #contrib - packages by Centos Users
46 │ [contrib]
47 │ name=CentOS-6.10 - Contrib - mirrors.aliyun.com
48 │ failovermethod=priority
49 │ baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
50 │ gpgcheck=1
51 │ enabled=0
52 │ gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
It’s using aliyun as the baseurl.
5. Summary
In this post, I demonstrated how to solve the baseurl problem when using yum on CentOS servers .