系统相关
首页 > 系统相关> > Centos6无法使用yum源解决方案(最简最优方案)

Centos6无法使用yum源解决方案(最简最优方案)

作者:互联网

1.yum介绍

        yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及SUSE中的Shell前端软件包管理器。基於RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载、安装。yum提供了查找、安装、删除某一个、一组甚至全部软件包的命令。

2.背景

        虚拟机安装了Centos6.8,通过yum源安装软件报错,发现无法安装

[root@hadoop03 usr]# yum install -y openssh-clients
已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
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
错误:Cannot find a valid baseurl for repo: base

3.方案

3.1 方案一

根据错误查看网上材料,大部分解决方案,是要求更新/etc/yum.repos.d/CentOS-Base.repo镜像源(比如阿里云镜像),操作如下

#1.首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

#2、进入yum源配置文件所在的文件夹
cd /etc/yum.repos.d/

#3、查看CentOS系统版本
lsb_release -a

#4、下载ailiyun的yum源配置文件到/etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

-bash: wget: command not found

提示 “-bash: wget: command not found”。由于yum源本身的问题,无法通过yum源下载wget

yum install wget -y

已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
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
错误:Cannot find a valid baseurl for repo: base

3.2 方案二

先把之前的repo挪到备份,然后下面两个二选一

源一:替换为官方Vault源(海外服务器用)
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Official.repo

源二:阿里云Vault镜像(国内服务器用)
curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo

yum源下载wget正常,其他问题迎刃而解

yum install wget -y

已加载插件:fastestmirror
设置安装进程
Loading mirror speeds from cached hostfile
base                                                                                                                                                                                                        | 3.7 kB     00:00     
base/primary_db                                                                                                                                                                                             | 4.7 MB     00:00     
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:00     
解决依赖关系
--> 执行事务检查
---> Package wget.x86_64 0:1.12-10.el6 will be 安装
--> 完成依赖关系计算

依赖关系解决

===================================================================================================================================================================================================================================
 软件包                                              架构                                                  版本                                                          仓库                                                 大小
===================================================================================================================================================================================================================================
正在安装:
 wget                                                x86_64                                                1.12-10.el6                                                   base                                                484 k

事务概要
===================================================================================================================================================================================================================================
Install       1 Package(s)

总下载量:484 k
Installed size: 1.8 M
下载软件包:
wget-1.12-10.el6.x86_64.rpm                                                                                                                                                                                 | 484 kB     00:00     
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>"
 From  : http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
运行 rpm_check_debug 
执行事务测试
事务测试成功
执行事务
  正在安装   : wget-1.12-10.el6.x86_64                                                                                                                                                                                         1/1 
  Verifying  : wget-1.12-10.el6.x86_64                                                                                                                                                                                         1/1 

已安装:
  wget.x86_64 0:1.12-10.el6                                                                                                                                                                                                        

完毕!

标签:最简,CentOS,etc,00,repo,Centos6,yum,wget
来源: https://blog.csdn.net/weixin_38023225/article/details/120998585