Centos6 使用 yum 命令是提示 yum 源不存在

Centos6 使用 yum 命令安装软件时报错

从2020年12月开始,将 CentOS6 相关的软件源移出了官方源,这样在使用 yum 命令安装软件时会出现如下错误:

[root@ora2 ~]# yum install -y vim
Loaded plugins: fastestmirror
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

解决方法如下:

step1 关闭 fastestmirrors

执行如下命令:

vi /etc/yum/pluginconf.d/fastestmirror.conf
​
[main]
enabled=0  # 把 enabled 选项的参数由 1 改为 0
verbose=0
always_print_best_host = true
socket_timeout=3
#  Relative paths are relative to the cachedir (and so works for users as well
# as root).
hostfilepath=timedhosts.txt
maxhostfileage=10
maxthreads=15
#exclude=.gov, facebook
#include_only=.nl,.de,.uk,.ie

step2 设置 yum 源

执行如下命令:

[root@ora1 ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
[root@ora1 ~]# cd /etc/yum.repos.d/
[root@ora1 yum.repos.d]# ls
CentOS-Base.repo.bak  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo
​
[root@oracle yum.repos.d]# yum clean all
Cleaning repos: 
Cleaning up Everything
[root@oracle yum.repos.d]# yum makecache
Metadata Cache Created
​
​
[root@ora1 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  1749  102  1749    0     0   2096      0 --:--:-- --:--:-- --:--:--  9825

step3 测试 yum 命令

yum 安装文本编辑器 vim,OK!

[root@ora1 yum.repos.d]# yum install -y wget
base                                                          | 3.7 kB     00:00     
base/primary_db                                               | 4.7 MB     00:03     
extras                                                        | 3.4 kB     00:00     
extras/primary_db                                             |  29 kB     00:00     
updates                                                       | 3.4 kB     00:00     
updates/primary_db                                            |  12 MB     00:09     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-10.el6 will be installed
--> Finished Dependency Resolution
​
Dependencies Resolved
​
====================================&
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值