linux怎么查看本机内存大小
302
2022-10-19
【在下版本,有何贵干?】Dockerfile中 RUN yum -y install vim失败Cannot prepare internal mir
隐秘的版本问题————
Dockerfile中 RUN yum -y install vim失败Cannot prepare internal mirrorlist: No URLs in mirrorlist
目录:写在前面:心得+本文精华(本文该问题的思考解决方式)写在后面:为解决本文该问题----我的折腾
☺ 心得+本文精华(本文该问题的思考解决方式)♡ 心得:修改文件,记得备份!尤其是配置文件♡ 本文该问题的思考解决方式:实际上就是开发中遇到的版本问题
一、问题
1、系统版本:linux版本centos7.6(1080)
2、错误背景:我想要自定义tomcat环境镜像,通过build Dockerfile的方式
Dockerfile 文件内容如下:
FROM centosMAINTAINER ylb<11>ADD jdk-8u301-linux-aarch64.tar.gz /usr/local/ADD apache-tomcat-9.0.62.tar.gz /usr/local/RUN yum -y install vimENV MYPATH /usr/local/WORKDIR $MYPATHENV JAVA_HOME /usr/local/jdk1.8.0_301ENV CLASSPATH $JAVA_HOME/lib/ENV CATALINA_HOME /usr/local/apache-tomcat-9.0.62ENV CATALINA_BASH /usr/local/apache-tomcat-9.0.62ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin:$CATALINA_HOME/libEXPOSE 8080CMD /usr/local/apache-tomcat-9.0.62/bin/startup.sh && tail -F /usr/local/apache-tomcat-9.0.62/logs/catalina.out
3、错误发生:执行到RUN yum -y install vim就报错,Cannot prepare internal mirrorlist: No URLs in mirrorlist
4、错误原因:
究其根因是版本问题
学习docker的视频,我跟着狂神的视频,为了减少错误,我选择和他系统保持一致,安装的软件、镜像、容器的版本等等(涉及到版本的)都保持一致
但是,问题在于,狂神的视频发布的时间和现在不同,视频的last版本,是他当时的last
大白话就是,狂神当时(last)最新的centos版本是7.xx,而现在(last)最新的版本的centos是8.xxx
出现版本原因的还有yum
伴随着不同centos版本所兼容的yum,它的内容是不同的
举例:Centos-vault-6.10.repo 和 Centos-vault-8.5.2111.repo的对比:发现版本6的内容比较少,它相对于8的话,没有[centosplus]、[PowerTools]、[AppStream]
最最重要的是:本次问题报错所没有AppStream,而这个AppStream是版本8的centos才有的,是版本8的新增内容,在版本7是没有它的,官网没有提供!
☺ 认识到版本的重要性了吧,内容的增删改!
二、正确解决方式
方式1:升级centos系统为版本8的,然后再使用build Dockerfile
方式2:涉及到centos版本的地方,指明版本,如本文问题核心Dockerfile中的 FROM centos:7
指定dockerfile的centos版本
三、为什么我知道"这个AppStream是版本8的centos才有的,是版本8的新增内容,在版本7是没有它的,官网没有提供"
1、线索1:搜索问题"Cannot prepare internal mirrorlist: No URLs in mirrorlist"
发现:
解释了问题原因:
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到URLs in mirrorlist error,找到某一篇文章,他提供了一种解决方案:
3)提取链接到浏览器,把版本对应不上的参数去掉,得到:
版本是7
发现:
搜索出来的版本都是8的,这个是一个提示点
☺ 为解决本文该问题----我的折腾结果是无效折腾
1、错误原因:
搜索得知错误原因,看到了centos版本是8,以为是所有的版本都一样,然后,将别人文章centos版本8版本,直接改成7,以为就完美解决问题
在2022年1月31日,CentOS团队终于从官方镜像中移除CentOS 8的所有包。
CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到Linux 8 - AppStream 21 B/s | 38 B 00:01 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlistThe command '/bin/sh -c yum -y install vim' returned a non-zero code: 1
2、解决手段:
① 如果你仍然需要运行你的旧CentOS 8,你可以在/etc/yum.repos中更新repos.d使用vault.centos.org代替mirror.centos.org。
cd /etc/yum.repos.dvi CentOS-AppStream.repo
[appstream]name=CentOS $releasever - AppStream#mirrorlist=gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
② 执行命令:
yum clean allyum makecache
2-2、又发生错误:
[Errno 14] HTTPS Error 404 - Not Found
Determining fastest mirrors[Errno 14] HTTPS Error 404 - Not FoundTrying other mirror.To address this issue please refer to the below wiki article above article doesn't help to resolve this issue please use One of the configured repositories failed (CentOS Linux 7 - AppStream), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=appstream ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable appstream or subscription-manager repos --disable=appstream 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=appstream.skip_if_unavailable=truefailure: repodata/repomd.xml from appstream: [Errno 256] No more mirrors to try.[Errno 14] HTTPS Error 404 - Not Found
2-2、错误原因:
是因为yum已经更新了的原因导致的进官网可以看到已经更新到7.x了打开CentOS7-Base.repo(名字可能不一样),一般在 ./etc/yum.repos.d文件夹下
vim /etc/yum.repos.d/CentOS7-Base.repo# 将其中baseurl中的$releasever全改为7
2-2、解决手段:
解决阿里云CentOS7 yum安装appstream报错,更新yum后无法makecache的问题将/etc/yum.repos.d/CentOS-AppStream.repo,替换为如下:
[appstream]name=CentOS-$releaseverbaseurl=/etc/yum.repos.d/ && mkdir backup && mv *repo backup/
2)下载阿里源文件
curl -o /etc/yum.repos.d/CentOS-Base.repo -i -e "s|mirrors.cloud.aliyuncs.com|mirrors.aliyun.com|g " /etc/yum.repos.d/CentOS-*sed -i -e "s|releasever|releasever-stream|g" /etc/yum.repos.d/CentOS-*
4)生成缓存
yum clean all && yum makecache
3-2、又报错
问题是:执行第四步yum clean all && yum makecache报错:failure: repodata/repomd.xml from AppStream: [Errno 256] No more mirrors to try.
One of the configured repositories failed (CentOS-7-stream - AppStream - mirrors.aliyun.com), and yum doesn't have enough cached data to continue. At this point the only safe thing yum can do is fail. There are a few ways to work "fix" this: 1. Contact the upstream for the repository and get them to fix the problem. 2. Reconfigure the baseurl/etc. for the repository, to point to a working upstream. This is most often useful if you are using a newer distribution release than is supported by the repository (and the packages for the previous distribution release still work). 3. Run the command with the repository temporarily disabled yum --disablerepo=AppStream ... 4. Disable the repository permanently, so yum won't use it by default. Yum will then just ignore the repository until you permanently enable it again or use --enablerepo for temporary usage: yum-config-manager --disable AppStream or subscription-manager repos --disable=AppStream 5. Configure the failing repository to be skipped, if it is unavailable. Note that yum will try to contact the repo. when it runs most commands, so will have to try and fail each time (and thus. yum will be be much slower). If it is a very temporary problem though, this is often a nice compromise: yum-config-manager --save --setopt=AppStream.skip_if_unavailable=truefailure: repodata/repomd.xml from AppStream: [Errno 256] No more mirrors to try.[Errno 12] Timeout on (28, 'Connection timed out after 30000 milliseconds')[Errno 14] HTTPS Error 404 - Not Found[Errno 14] HTTP Error 404 - Not Found[Errno 12] Timeout on (28, 'Connection timed out after 30001 milliseconds')[Errno 12] Timeout on (28, 'Connection timed out after 30001 milliseconds')[Errno 12] Timeout on (28, 'Connection timed out after 30000 milliseconds')[Errno 12] Timeout on (28, 'Connection timed out after 30001 milliseconds')[Errno 12] Timeout on (28, 'Connection timed out after 30001 milliseconds')[root@iZwz9535z41cmgcpkm7i81Z yum.repos.d]#
3-2、错误原因是:在于yum源问题
3-2、解决手段:解决yum源问题
1)查看centos系统本身所安装的yum依赖包
rpm -qa|grep yum
2)卸载这些软件包 rpm -e xx --nodeps
进入centos镜像网站找到自己对应系统需要的yum包
查看系统的命令:
cat /etc/redhat-release
查看系统的位数:
file /bin/ls
下载yum依赖包:
网站:-ivh yum-*
6)更换CentOS-Base.repo
① 进入 /etc/yum.repos.d,先备份
cd /etc/cd yum.repos.d# 备份一下:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
② 进入官网:传输到/etc/yum.repos.d目录
# 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=updates[updates]name=CentOS-$releasever - Updates#mirrorlist=packages that may be useful[extras]name=CentOS-$releasever - Extras#mirrorlist=packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus#mirrorlist=执行命令:
yum clean allyum makecache
还报错,你以为到这里,我就放弃了吗?---yes, 我的贪吃蛇已经快排名第一了哈哈哈继续解决~~~
二、继续我的不正确解决手段:
哇塞,玩完贪吃蛇的我,不一样了,眼睛不一样了,一瞅,立马发现了,自己的centos的配置文件下的yum.repos.d/目录下的文件和别人不同发现缺少文件了
1、再搜索问题,发现缺少文件了
"将/etc/yum.repos.d/目录下的CentOS-Base.repo、CentOS-AppStream.repo、CentOS-Extras.repo中的mirrorlist注释掉,将baseurl 修改为阿里源......"
2、解决方式1【结果悲捶了,只剩下一个Centos-Base.repo文件了-----说明了备份的重要性】:
将/etc/yum.repos.d 清空后,重新下载
# 删除yum.repos.d目录下所有文件rm -f /etc/yum.repos.d/*# 然后重新下载阿里的源(确保网络连接)--注意版本哦,我的centos是7的版本wget -O /etc/yum.repos.d/CentOS-Base.repo 清理缓存yum clean all
☺ 心得:修改文件,记得备份!● 所以,咱没备份,配置文件全没了,咱重置一下系统吧
☺ 重置Linux系统
在阿里云官网上找到你购买的那个服务器,点一下重置系统,选择centos7,然后重置一下密码
1、重置系统过后、发现/etc/yum.repos.d/目录下:
CentOS-Base.repoepel.repo
2、重新安装docker、配置阿里云镜像加速
(1)安装
帮助文档:1、卸载旧版本:sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-engine # 2、使用仓库安装 # 需要的安装包 sudo yum install -y yum-utils # 设置仓库【默认是国外的,我们不要使用国外的,需要使用国内的阿里云镜像地址】 sudo yum-config-manager \ --add-repo \ # 更新yum 软件包索引 yum makecache fast # 3、安装 Docker 引擎 docker-ce 社区 docker-ee 企业版 yum install docker-ce docker-ce-cli containerd.io # 4、启动 Docker systemctl start docker # 检查是否成功启动 docker version # 5、测试hello-world docker run hello-world # 查看下载的镜像 docker images
3、阿里云镜像加速
镜像加速器:
(2)配置使用:
sudo mkdir -p /etc/dockersudo tee /etc/docker/daemon.json <<-'EOF'{ "registry-mirrors": ["systemctl daemon-reloadsudo systemctl restart docker
● 发现/etc/yum.repos.d/目录下:
CentOS-Base.repodocker-ce.repoepel.repoepel.repo.rpmnewepel-testing.repo
三、错误依旧
折腾累了,贪吃蛇也玩得手指起泡了,突然这次又火眼金睛,发现了阿里、腾讯镜像中,好奇对比一下centos7—Base.repo 和 centos8—Base.repo,还有,之前搜索发现:CentOS团队终于从官方镜像中移除CentOS 8的所有包。CentOS 8已于2021年12月31日寿终正非,但软件包仍在官方镜像上保留了一段时间。现在他们被转移到和 Centos-vault-8.5.2111.repo (因为没有版本7的,所以找6的来对比)恍惚之间,想到了时间是一把杀猪刀,现在是2022年了,而我的学习视频,狂神的Docker最新超详细版教程通俗易懂视频,是2020年的在下版本,有何贵干!
作者:一乐乐
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~