centos7下安装yum记录(yum命令失败:cannot find a valid baseurl for repo: base/7/x86

网上找了好久,都过时了,自己鼓捣了半天,终于安装完成,记录一下。

第一步:先看本地yum是否安装

直接linux下输入yum查看

提示这样的都是安装成功的,可以跳过安装卸载这步,直接看第四步。提示别的就是安装失败了,需要卸载重装。

第二步:卸载

这步我都是网上搜索的命令,最后卸完了,输入yum没有提示上面的就行,命令没记录,大概是这几个,可以参考下:
rpm -qa yum —查看yum(安装了的话会提示具体的,如下图没有的话就不用卸载)

rpm -qa | grep yum | xargs rpm -e --nodeps --卸载

第三部:安装yum

这一步我是找的百度经验的,链接直接粘过来:
https://jingyan.baidu.com/article/ce09321bbde1de2bff858f9a.html
这个一定要到自己对应的版本去找,需要按照图上的地址一步一步来,这里要注意的是第七步命令会报错,这里改下图片里面的命令,使得rpm安装时忽略依赖:
rpm -ivh yum-* --nodeps --force
安装完后执行第一步的命令应该是成功的。

第四步:yum命令失败解决

我的失败报错是这个,别的可能不适用:
cannot find a valid baseurl for repo: base/7/x86_64
这个报错是因为yum配置源不对的问题,这个配置文件在/etc/yum.repos.d/ 目录下的CentOS-Base.repo(简单的来说就是下载一个阿里或者163的yum源配置文件,文件名字不一样的改成CentOS-Base.repo)

---下载阿里云yum镜像源
1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后运行 yum clean all,yum makecache 生成缓存

----163yum镜像源

第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
3、之后运行 yum clean all,yum makecache 生成缓存
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

这里执行yum makecache时候会报404的错误,是因为对应的地址没有资源。
我们打开文件,修改baseurl为正确的地址就好,下面附我改完的,你需要去对应网址看看有没有这个路径。

# 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/7/os/x86_64/
        http://mirrors.aliyuncs.com/centos/7/os/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/
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/7/updates/x86_64/
        http://mirrors.aliyuncs.com/centos/7/updates/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos/7/updates/x86_64/
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/7/extras/x86_64/
        http://mirrors.aliyuncs.com/centos/7/extras/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos/7/extras/x86_64/
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/7/centosplus/x86_64/
        http://mirrors.aliyuncs.com/centos/7/centosplus/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos/7/centosplus/x86_64/
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/7/contrib/x86_64/
        http://mirrors.aliyuncs.com/centos/7/contrib/x86_64/
        http://mirrors.cloud.aliyuncs.com/centos/7/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62

改完后执行yum命令就可以正常执行了。

(0)

相关推荐

  • (3条消息) Centos7下安装Docker(详细安装教程)

    一,Docker简介 百科说:Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚拟化,容器是完全使用沙 ...

  • CentOS 7 新装服务器部署流程

    CentOS 7 新装服务器部署流程

  • CentOS7下安装Consul和自启动配置

    安装 1.下载Consul [root@localhost 20190903] wget https://releases.hashicorp.com/consul/0.9.3/consul_0.9. ...

  • CENTOS7下安装REDIS

    阅读目录 第一步:下载redis安装包 第二步:解压压缩包 第三步:yum安装gcc依赖 第四步:跳转到redis解压目录下 第五步:编译安装 1.直接启动redis 2.以后台进程方式启动redis ...

  • centos7下安装erlang

    背景 emqx中使用到了erlang作为其运行前提,为了编译相关插件,这里分享下如何在cento7下安装erlang. 安装方式 erlang两种主流安装方式: 1. 源码安装:http://erla ...

  • 记录下在CentOS7中安装Docker CE

    记录下在CentOS7中安装Docker CE 1. 卸载系统中可能存在的老版本 在CentOS中,老版本Docker的软件包名是docker或docker-engine,而Docker CE的软件包 ...

  • VirtualBox下安装CentOS7系统超详细图文详解

    欢迎关注微信公众号:[ 全栈攻略 ] VirtualBox的安装非常简单就不累述了,安装好了VirtualBox之后,我们需要下载安装CentOS7镜像包,可以参考我的另一篇博文 CentOS7安装和 ...

  • (1条消息) centos7下 rabbitmq erlang 的下载地址,的安装,源码安装,rpm安装

    erlang 与 rabbitmq 正确的版本匹配 https://www.rabbitmq.com/which-erlang.html erlang下载地址 :1  http://erlang.or ...

  • Centos7.7系统下安装SQL Server 2019

    SQL Server 2019 为所有数据工作负载带来了创新的安全性和合规性功能.业界领先的性能.任务关键型可用性和高级分析,现在还支持内置的大数据. 准备工作 系统版本:Centos7.7 ,内存4 ...

  • linux下(centos7)docker安装

    参考链接https://docs.docker.com/install/linux/docker-ce/centos/ 第一步,确定是centos7及以上版本 cat /etc/redhat-rele ...