虚拟机安装以后yum安装失败,不能访问镜像

313 阅读1分钟

宝塔安装

yum install -y wget && wget -O install.sh download.bt.cn/install/ins… && sh install.sh ed8484bec 出现错误

错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: No URLs 

解决办法

1、首先查看系统镜像问题

[root@localhost ~]#  cat CentOS-Linux-BaseOS.repo
cat: CentOS-Linux-BaseOS.repo: 没有那个文件或目录
[root@localhost ~]#  cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
CentOS-Linux-AppStream.repo          CentOS-Linux-Devel.repo             CentOS-Linux-Media.repo
CentOS-Linux-BaseOS.repo             CentOS-Linux-Extras.repo            CentOS-Linux-Plus.repo
CentOS-Linux-ContinuousRelease.repo  CentOS-Linux-FastTrack.repo         CentOS-Linux-PowerTools.repo
CentOS-Linux-Debuginfo.repo          CentOS-Linux-HighAvailability.repo  CentOS-Linux-Sources.repo
[root@localhost yum.repos.d]# cat CentOS-Linux-BaseOS.repo
# CentOS-Linux-BaseOS.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[baseos]
name=CentOS Linux $releasever - BaseOS
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
[root@localhost yum.repos.d]# cat CentOS-Linux-BaseOS.repo
# CentOS-Linux-BaseOS.repo
#
# The mirrorlist system uses the connecting IP address of the client and the
# update status of each mirror to pick current mirrors that are 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, you can try the commented out
# baseurl line instead.

[baseos]
name=CentOS Linux $releasever - BaseOS
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial 

2、切换为阿里云镜像

[root@localhost yum.repos.d]# mkdir backup && mv CentOS-Linux-*.repo backup //备份原来的镜像
[root@localhost yum.repos.d]# yum install wget //验证
错误:在"/etc/yum.repos.d", "/etc/yum/repos.d", "/etc/distro.repos.d"中没有被启用的仓库。
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Linux-Base-ali.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo //切换为阿里云镜像
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0   9486      0 --:--:-- --:--:-- --:--:--  9450
[root@localhost yum.repos.d]# yum -y install wgetyum -y install wget
CentOS-8.5.2111 - Base - mirrors.aliyun.com                                             1.6 MB/s | 4.6 MB     00:02
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                                            30 kB/s |  10 kB     00:00
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                                        904 kB/s | 8.4 MB     00:09
未找到匹配的参数: wgetyum
未找到匹配的参数: install
软件包 wget-1.19.5-10.el8.x86_64 已安装。
错误:没有任何匹配: wgetyum install