2、备份文件

备份这三个文件就行了
(注意!!很多人只有 CentOS-Base.repo 文件,没有后两个,这也没问题,有几个备份几个,不用额外创建!)
在这里插入图片描述

3、编辑CentOS-Base.repo 文件(必选)

!!! 警告,在编辑文件的时候,你肯定是复制黏贴下面的内容的。但是,vim 编辑器会有个黏贴反应时间,所以大概率你在黏贴了内容之后,最开头的内容会缺少 1-5 个字符,你需要手动补全,下面的编辑也是一样 !!!

vi /etc/yum.repos.d/CentOS-Base.repo
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">

全选替换:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

#contrib - packages by Centos Users
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}"> class="hide-preCode-box">

或者

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
 
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}"> class="hide-preCode-box">
4、编辑 CentOS-SCLo-scl-rh.repo 文件(如果没有这个文件,不用管)

编辑 CentOS-SCLo-scl-rh.repo 文件:

vi /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">

替换内容: ***注意哦!!!***这里不是全部替换,只替换【centos-sclo-rh】下面的内容。

[centos-sclo-rh]
name=CentOS-$releasever - SCLo rh
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">
5、编辑 CentOS-SCLo-scl.repo 文件(如果没有这个文件,不用管)

编辑 CentOS-SCLo-scl.repo 文件:

vi /etc/yum.repos.d/CentOS-SCLo-scl.repo
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">

替换内容为:

[centos-sclo-sclo]
name=CentOS-$releasever - SCLo sclo
baseurl=https://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">
6、清理缓存、重新加载缓存

①清理缓存

yum clean all
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">
[root@node1 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base centos-sclo-rh centos-sclo-sclo extras updates
Cleaning up list of fastest mirrors
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">

②加载缓存

yum makecache
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}">
[root@node1 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
base                                                                                                               | 3.6 kB  00:00:00
centos-sclo-rh                                                                                                     | 3.0 kB  00:00:00
centos-sclo-sclo                                                                                                   | 3.0 kB  00:00:00
extras                                                                                                             | 2.9 kB  00:00:00
updates                                                                                                            | 2.9 kB  00:00:00
(1/16): base/7/x86_64/group_gz                                                                                     | 153 kB  00:00:00
(2/16): base/7/x86_64/primary_db                                                                                   | 6.1 MB  00:00:24
(3/16): base/7/x86_64/filelists_db                                                                                 | 7.2 MB  00:00:31
(4/16): base/7/x86_64/other_db                                                                                     | 2.6 MB  00:00:10
(5/16): centos-sclo-rh/7/x86_64/primary_db                                                                         | 3.4 MB  00:00:15
(6/16): centos-sclo-sclo/7/x86_64/primary_db                                                                       | 300 kB  00:00:01
(7/16): centos-sclo-sclo/7/x86_64/other_db                                                                         | 185 kB  00:00:00
(8/16): extras/7/x86_64/filelists_db                                                                               | 305 kB  00:00:01
(9/16): extras/7/x86_64/primary_db                                                                                 | 253 kB  00:00:01
(10/16): centos-sclo-sclo/7/x86_64/filelists_db                                                                    | 935 kB  00:00:03
(11/16): extras/7/x86_64/other_db                                                                                  | 154 kB  00:00:00
(12/16): centos-sclo-rh/7/x86_64/other_db                                                                          | 1.6 MB  00:00:05
(14/16): updates/7/x86_64/filelists_db                 61% [=========                                                                     (13/16): centos-sclo-rh/7/x86_64/filelists_db   |  12 MB   00:49
(14/16): updates/7/x86_64/filelists_db                                                                             |  15 MB  00:01:09
(15/16): updates/7/x86_64/other_db                                                                                 | 1.6 MB  00:00:06
(16/16): updates/7/x86_64/primary_db                                                                               |  27 MB  00:01:50
Metadata Cache Created
 class="hljs-button signin active" data-title="登录复制" data-report-click="{"spm":"1001.2101.3001.4334"}"> class="hide-preCode-box">

到此!yum install 报错问题解决,希望可以帮到您!

> > data-report-view="{"mod":"1585297308_001","spm":"1001.2101.3001.6548","dest":"https://blog.csdn.net/weixin_43887285/article/details/142631406","extend1":"pc","ab":"new"}">>
注:本文转载自blog.csdn.net的书笑生的文章"https://blog.csdn.net/weixin_48101150/article/details/118732507"。版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。如有侵权,请联系我们删除。
复制链接

评论记录:

未查询到任何数据!