CentOS7.2 yum安装报错

时间:2021-09-06 08:38:10

1、yum源repodata配置文件repomd.xml无法找到

Couldn't open file /mnt/cdrom/repodata/repomd.xml

CentOS7.2 yum安装报错

先找到repomd.xml的路径

find / -type f -name "repomd.xml"

CentOS7.2 yum安装报错

我们看到路径是:/mnt

而报错的路径是:/mnt/cdrom

查看挂载点有mnt,故,我们需要找到这个路径,将 /mnt/cdrom修改为/mnt

CentOS7.2 yum安装报错

去配置repodata/repomd.xml路径

cd /etc/yum.repos.d/

CentOS7.2 yum安装报错

vi CentOS-Media.repo

CentOS7.2 yum安装报错

将路径改成我们找到的路径:将 /mnt/cdrom修改为/mnt

CentOS7.2 yum安装报错

保存执行yum源

yum clean all

yum makecache

测试:用yum成功安装telnet:

yum install telnet

CentOS7.2 yum安装报错

2、yum源没有配置repodata仓库

Error downloading packages:

iptables-1.4.21-16.el7.i686: [Errno 256] No more mirrors to try.

libmnl-1.0.3-7.el7.i686: [Errno 256] No more mirrors to try.

libnetfilter_conntrack-1.0.4-2.el7.i686: [Errno 256] No more mirrors to try.

libnfnetlink-1.0.1-4.el7.i686: [Errno 256] No more mirrors to try.

CentOS7.2 yum安装报错

 测试查询原因

yum list

df -h

 CentOS7.2 yum安装报错

报错的路径是:/mnt/cdrom

df -h没有找到/mnt

我们可以直接线上搭建一个仓库,所以前提条件是要连接上百度,这里就引申出第3个问题:

 

3、无法连接百度,无法解析域名

ping: unknown host www.baidu.com

ping www.baidu.com

CentOS7.2 yum安装报错

host www.baidu.com

CentOS7.2 yum安装报错

针对无法连接百度,我目前遇到有两种:

1)有DNS:给   /etc/resolv.conf 添加上 nameserver=xxx.xxx.xxx.xxx(DNS码)

cat /etc/sysconfig/network-scripts/ifcfg-enxxxx

vi /etc/resolv.conf

CentOS7.2 yum安装报错

2)无DNS:给   /etc/resolv.conf 添加上 nameserver=8.8.8.8(DNS码)

nameserver=8.8.8.8

测试:

第一步:备份你的原镜像文件,以免出错后可以恢复。
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/

查看:
curl -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

下载:

wget-O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo