centos os7 和redhat 7 安装yum源失败的解决办法

首先看我的报错

[Errno 14] curl#6 - "Could not resolve host: mirrors.aliyun.com; Unknown error"

yum源配置出现了问题

cd /etc/yum.repos.d/
vi local.repo#里面装的是Centos-7.repo Centos-Base.repo
查看内容如下
# CentOS-Base.repo
#
# The mirror system uses the connecting
# update status of each mirror to pick 
# geographically close to the client.  
# unless you are manually picking other
#
# If the mirrorlist= does not work for 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - mirror
failovermethod=priority
baseurl=http://mirrors.aliyun.com/cento
        http://mirrors.aliyuncs.com/cen
        http://mirrors.cloud.aliyuncs.c
        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/

就会发现$releasever重复出现多次,导致url地址不正确
验证:
1.复制url地址到浏览器中看是否能够访问
image

访问不了,说明url地址确实出现了错误
修改url地址
输入 ":" 进入末行模式
然后输入 %s/$releasever/7/g
保存并退出
然后发现有了新的问题
yum clean all
报错

Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Cleaning repos: base etras extras
     ...: train updates updatess virt
Other repos take up 11 M of disk space (use --verbose for details)

Loaded plugins: fastestmirror

fastestmirror是yum的一个加速插件

这个地方是插件提示信息
意思是插件不能用了。
既然不能用了,那我们就禁用它

1.修改插件的配置文件

vi /etc/yum/pluginconf.d/fastestmirror.conf

enabled = 1//由1改为0,禁用该插件

2.修改yum的配置文件
vi /etc/yum.conf

plugins=1//改为0,不使用插件

3 清除缓存并重新构建yum 源
yum clean all
yum clean dbcache
yum makecache

然后发现仍然yum clean不成功

Repository base is listed more than once in the configuration

说有重复的名称

改名字或者删除
这里我选择删除掉aliyun的yum源

总结

[root@controller yum.repos.d]# rm -f *  /etc/yum.repos.d/
[root@controller yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Cleaning repos: base epel extras train updates virt
Cleaning up list of fastest mirrors
# 这些不是报错 是因为我有repo源可以用 所以有这些输出信息

# 本地配置
[root@compute ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@compute yum.repos.d]# vim loo.repo
[local]
name=local
baseurl=file:///mnt
gpgcheck=0
enabled=1

# 网络拉取
[root@compute yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

[root@compute yum.repos.d]# yum repolist all

image

这个时候看到我们刚才配的仓库对应是数字 他的软件包的数量

总结一下

1.yum源是国内网站的时候要注意自己的网卡配置,能不能上网
2.yum源配置[]里的名字唯一,不要重复(如果有重复的,就在后面加-aliyun)
3.yum源配置信息里url路径 http、https|file
4.插件不用禁止
5.如果排查不到原因,建议直接删除repo文件,重新搭建yum源。(这个时候可以去阿里云直接拉去,没有网络就本地挂载iso)

posted on 2023-10-25 17:05  代码你敲我不敲  阅读(757)  评论(1编辑  收藏  举报

导航

返回顶端