使用docker时报错:YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. Invalid ...

1 全部内容

全部报错是这样的:

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

Error: Cannot find a valid baseurl for repo: base

2 起因与经过

起因是这样的,为了图方便直接下载了docker的官方hadoop镜像,而本萌新以前都是自己配docker自己用的, 也不清楚这个官方hadoop镜像用的是centos,于是在vim core-site.xml遇到了这个报错:

bash-4.1# vim core-site.xml

bash: vim: command not found

这部直接给他下载一个,于是不加思索键入了apt-get install -y vim,不出意料地得到了如下的错误:

bash-4.1# apt-get install -y vim

bash: apt-get: command not found

查了一下,得知这个镜像是centos系统的,当然没有apt-get了,于是键入了如下命令:

yum -y install vim

便有了开头的那段报错 .

3 解决方案

参考了这位老哥的博客:

YumRepo Error: All mirror URLs are not using ftp, http[s] or file. Eg. Invalid release/repo/archhttps://blog.csdn.net/wwzzh1989/article/details/123290331原因就是该版本的centos停止维护了,官方源已经没有用了,所以YUM会报错!!!

解决思路就是去更换yum的源,具体操作如下:

1. 打开yum的配置文件:       

vi /etc/yum.repos.d/CentOS-Base.repo 

2. 注释掉所有以mirrorlist开头的行

3. 解开所有以baseurl开头的行

4. 修改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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/centosplus/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://mirrors.aliyun.com/centos-vault/6.6/contrib/x86_64/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
~                                 

接着,再次运行:

yum -y install vim

发现依然存在问题,报错如下:

Total download size: 6.8 M

Installed size: 19 M

Downloading Packages:

(1/2): vim-common-7.2.411-1.8.el6.x86_64.rpm | 6.0 MB 00:11

http://mirrors.aliyun.com/centos-vault/6.6/os/x86_64/Packages/vim-common-7.2.411-1.8.el6.x86_64.rpm: [Errno -1] Package does not match intended download. Suggestion: run yum --enablerepo=base clean metadata

Trying other mirror.

(2/2): vim-enhanced-7.2.411-1.8.el6.x86_64.rpm | 892 kB 00:02

http://mirrors.aliyun.com/centos-vault/6.6/os/x86_64/Packages/vim-enhanced-7.2.411-1.8.el6.x86_64.rpm: [Errno -1] Package does not match intended download. Suggestion: run yum --enablerepo=base clean metadata

Trying other mirror.

Error Downloading Packages:

2:vim-common-7.2.411-1.8.el6.x86_64: failure: Packages/vim-common-7.2.411-1.8.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

2:vim-enhanced-7.2.411-1.8.el6.x86_64: failure: Packages/vim-enhanced-7.2.411-1.8.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.

于是按照提示尝试:

yum --enablerepo=base clean metadata

再次运行yum -y install vim,发现问题解决了!

END

posted @ 2023-01-13 09:41  TIM3347_Tian  阅读(56)  评论(0)    收藏  举报  来源