解决yum 安装包时报错

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
total 40
-rw-r--r--. 1 root root 1664 Oct 23  2020 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Oct 23  2020 CentOS-CR.repo
-rw-r--r--. 1 root root  649 Oct 23  2020 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 Oct 23  2020 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Oct 23  2020 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Oct 23  2020 CentOS-Sources.repo
-rw-r--r--. 1 root root 8515 Oct 23  2020 CentOS-Vault.repo
-rw-r--r--. 1 root root  616 Oct 23  2020 CentOS-x86_64-kernel.repo

备份CentOS-Base.repo

cp CentOS-Base.repo CentOS-Base.repo.bak

vi /etc/yum.repos.d/CentOS-Base.repo
:%s/$releasever/7.9.2009/g					 //将所有$releasever替换成7.9.2009
:%s/CentOS-7.9.2009/CentOS-Base/g			 //将CentOS-7.9.2009替换成文件名CentOS-Base
:wq!

注意事项
$releasever应替换成相对应的系统版本
name=CentOS-Base这里也要改成你自己的文件名,比如阿里云的文件名是Centos-7.repo,那就改成name=CentOS-7

下面是centos7.9.2009版本的yum源

# 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-Base - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-Base - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-Base - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-Base - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=7.9.2009&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 yum makecache
  yum update

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值